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"
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
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.
Attachments:
handle-exception-variable.patch 444 bytes
I haven't had time to review the exact patch, but I think I'd rather have it be python 3 syntax than python 2 syntax. Can it be changed to that? Like: except BlahException as e: ... Thanks! |
|
This second patch works with python 3 syntax (except X as x)
Attachments:
handle-exception-variable-2.patch 2.6 KB