Re: Issue 43 in tinypy: cannot catch an exception

10 views
Skip to first unread message

codesite...@google.com

unread,
Feb 5, 2010, 4:19:43 AM2/5/10
to tin...@googlegroups.com

Comment #1 on issue 43 by charlie137: cannot catch an exception
http://code.google.com/p/tinypy/issues/detail?id=43

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

codesite...@google.com

unread,
Feb 5, 2010, 11:19:47 AM2/5/10
to tin...@googlegroups.com

Comment #2 on issue 43 by charlie137: cannot catch an exception
http://code.google.com/p/tinypy/issues/detail?id=43

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

Phil Hassey

unread,
Feb 9, 2010, 4:04:22 PM2/9/10
to tin...@googlegroups.com
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!
-Phil

--- On Fri, 2/5/10, codesite...@google.com <codesite...@google.com> wrote:
--You received this message because you are subscribed to the Google Groups "tinypy" group.
To post to this group, send email to tin...@googlegroups.com.
To unsubscribe from this group, send email to tinypy+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tinypy?hl=en.


codesite...@google.com

unread,
Feb 10, 2010, 12:58:59 AM2/10/10
to tin...@googlegroups.com

Comment #3 on issue 43 by charlie137: cannot catch an exception
http://code.google.com/p/tinypy/issues/detail?id=43

This second patch works with python 3 syntax (except X as x)

Attachments:
handle-exception-variable-2.patch 2.6 KB

Reply all
Reply to author
Forward
0 new messages