python-3.xwebapp2

webapp2 import SyntaxError


import webapp2 is throwing exception error --> Traceback (most recent call last):

File "/homefolder/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3267, in run_code exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 5, in import webapp2

File "//anaconda3/lib/python3.7/site-packages/webapp2.py", line 571

except Exception, e:
                    ^
SyntaxError: invalid syntax

I found a related post, but that seems like an old post without recent updates.

webapp2 with python3.

Can someone please advise ?


Solution

  • That is perfectly valid python2 syntax:

    $ python
    Python 2.7.12 (default, Jul 01 2016, 15:36:53) [GCC] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> try:
    ...  os.listdir('.')
    ... except Exception, e:
    ...  pass
    ... 
    ['2018', '2015', '2017', '2016', '2019']
    

    But, as you observed, the syntax is invalid in python3. So things didn't change since the post you referenced, webapp2 remains compatible with python2 only.

    As a general approach the GAE team moved towards dropping altogether many of the GAE-specific libraries and frameworks instead of porting them to newer language versions (not only python!). Instead they lowered the sandbox restrictions allowing more 3rd party such libraries and frameworks to be used instead, see Why is Google App Engine Standard using PHP 5.5?