testtools/compat.py: oddities in handling of Python 2.x and Python 3.x
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testtools |
New
|
Undecided
|
Unassigned |
Bug Description
testtools/compat.py attempts to import _compat2x.py first, and if that fails, then imports _compat3x.py
There is an oddity in the try-except block though: after importing _compat2x.py, if the import does not throw an exception, the next line evaluates _compat2x -- is this a debugging line that's left over?
Also, in Fedora, our procedure is to byte-compile all the Python modules when installing (using python setup.py install -O1), which trips up RPM as _compat2x and _compat3x are both installed, and attempting to byte-compile _compat2x under Python 3.x fails:
File "/usr/lib/
raise exc_class, exc_obj, exc_tb
SyntaxError: invalid syntax
Though byte-compiling _compat3x under Python 2.x does not fail, at least with Python 2.7.
Yes, that looks like a debugging line. I'll fix that now.
On the byte compiling side, we suggest you either only copy the compat module you need into your package, or handle a file not byte compiling, as so far we've been unable to implement a both-versions parsable version of these helpers.