Google Appengine and Python exceptions

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2010-01-28T00:34:50Z Indexed on 2010/03/15 0:29 UTC
Read the original article Hit count: 545

In my Google Appengine application I have defined a custom exception InvalidUrlException(Exception) in the module 'gvu'. Somewhere in my code I do:

try:
    results = gvu.article_parser.parse(source_url)
except gvu.InvalidUrlException as e:
    self.redirect('/home?message='+str(e))
...

which works fine in the local GAE development server, but raises

<type 'exceptions.SyntaxError'>: invalid syntax (translator.py, line 18)

when I upload it. (line 18 is the line starting with 'except')

The problem seems to come from the 'as e' part: if I remove it I don't get this exception anymore. However I would like to be able to access the raised exception. Have you ever encountered this issue? Is there an alternative syntax?

© Stack Overflow or respective owner

Related posts about python

Related posts about google-app-engine