raise Exception(...)

This commit is contained in:
j 2016-06-04 00:39:01 +02:00
parent 7695a9c015
commit 1e3d2d24bb
2 changed files with 5 additions and 5 deletions

View file

@ -53,8 +53,8 @@ def decode_dict(x, f):
lastkey = None lastkey = None
while x[f] != 'e': while x[f] != 'e':
k, f = decode_string(x, f) k, f = decode_string(x, f)
#why is this needed # why is this needed
#if lastkey >= k: # if lastkey >= k:
# raise ValueError # raise ValueError
lastkey = k lastkey = k
r[k], f = decode_func[x[f]](x, f) r[k], f = decode_func[x[f]](x, f)
@ -81,9 +81,9 @@ def bdecode(x, sloppy = 1):
r, l = decode_func[x[0]](x, 0) r, l = decode_func[x[0]](x, 0)
# except (IndexError, KeyError): # except (IndexError, KeyError):
except (IndexError, KeyError, ValueError): except (IndexError, KeyError, ValueError):
raise ValueError, "bad bencoded data" raise ValueError("bad bencoded data")
if not sloppy and l != len(x): if not sloppy and l != len(x):
raise ValueError, "bad bencoded data" raise ValueError("bad bencoded data")
return r return r
def test_bdecode(): def test_bdecode():

View file

@ -17,7 +17,7 @@ def get(key):
if key in auth: if key in auth:
return auth[key] return auth[key]
print("please add key %s to json file '%s'" % (key, user_auth)) print("please add key %s to json file '%s'" % (key, user_auth))
raise Exception,"no key %s found" % key raise Exception("no key %s found" % key)
def update(key, value): def update(key, value):
user_auth = os.environ.get('oxAUTH', os.path.expanduser('~/.ox/auth.json')) user_auth = os.environ.get('oxAUTH', os.path.expanduser('~/.ox/auth.json'))