[Python-porting] Installing different files on Python 2/3

Dirkjan Ochtman dirkjan at ochtman.nl
Thu Jul 17 19:25:50 CEST 2014


On Thu, Jul 17, 2014 at 5:45 PM, Guido van Rossum <guido at python.org> wrote:
> The Py2 version can just call exec(code, gns, lns). It is Py2 syntax too!

That sounds like an awesome solution, but it doesn't quite solve the problem:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/djc/src/couchdb-python/couchdb/tests/__main__.py", line
11, in <module>
    from couchdb.tests import client, couch_tests, design, couchhttp, \
  File "couchdb/tests/view.py", line 12, in <module>
    from couchdb import view
  File "couchdb/view.py", line 56
    exec(string, {'log': _log}, globals_)
SyntaxError: unqualified exec is not allowed in function 'add_fun' it
is a nested function

The code is here:

https://github.com/djc/couchdb-python/blob/afdbe601/couchdb/view.py#L56

I read up a little on unqualified and qualified exec, but I couldn't
really figure out why that error is triggering in this case.

Cheers,

Dirkjan


More information about the Python-porting mailing list