You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
try/else on 2.6 fixup
This commit is contained in:
17
test/simple_source/bug25/02_try_else_loop.py
Normal file
17
test/simple_source/bug25/02_try_else_loop.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# From 2.4 test_binop.py bug is missing 'else:' in 2nd try.
|
||||
def test_constructor():
|
||||
for bad in "0", 0.0, 0j, (), [], {}, None:
|
||||
try:
|
||||
raise TypeError(bad)
|
||||
except TypeError:
|
||||
pass
|
||||
else:
|
||||
assert False, "%r didn't raise TypeError" % bad
|
||||
try:
|
||||
raise TypeError(bad)
|
||||
except TypeError:
|
||||
pass
|
||||
else:
|
||||
assert False, "%r didn't raise TypeError" % bad
|
||||
|
||||
test_constructor()
|
18
test/simple_source/bug25/03_try_else.py
Normal file
18
test/simple_source/bug25/03_try_else.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# From Python 2.4. test_cgi.py
|
||||
# Bug was in putting try block inside the ifelse statement.
|
||||
|
||||
# Note: this is a self testing program - will assert on failure.
|
||||
def do_test(method):
|
||||
if method == "GET":
|
||||
rc = 0
|
||||
elif method == "POST":
|
||||
rc = 1
|
||||
else:
|
||||
raise ValueError, "unknown method: %s" % method
|
||||
try:
|
||||
rc = 2
|
||||
except ZeroDivisionError:
|
||||
rc = 3
|
||||
return rc
|
||||
|
||||
assert 2 == do_test("GET")
|
Reference in New Issue
Block a user