Open GoogleCodeExporter opened 9 years ago
I think this error is normal. The first token after the except keyword should
be the
type of the exception we are looking for. e.g. :
class A:
pass
try:
raise A()
except A, ex:
print(ex)
This code also fails with tinypy, but in the print(ex) statement.
I also noticed that putting several exception clauses is not handled, e.g. :
class A: pass
class B: pass
try:
raise B()
except A: print("got A")
except B: print("got B")
will print "got A" instead of "got B"
Original comment by charlie...@gmail.com
on 5 Feb 2010 at 9:18
A first attempt to solve the issue. With this patch we can run example like
this one :
class A:
def msg(self):
return "hello"
try:
raise A()
except A, ex:
print("got this :", ex.msg())
The parenthesis in the raise are important, because tinypy won't automatically
instantiate A() like cpython would do.
Original comment by charlie...@gmail.com
on 5 Feb 2010 at 4:19
Attachments:
This second patch works with python 3 syntax (except X as x)
Original comment by charlie...@gmail.com
on 10 Feb 2010 at 5:58
Attachments:
Original issue reported on code.google.com by
arab.ga...@gmail.com
on 10 Jul 2009 at 6:11