testtools/compat.py: oddities in handling of Python 2.x and Python 3.x

Bug #1068961 reported by Michel Lind
6
This bug affects 1 person
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/python3.3/site-packages/testtools/_compat2x.py", line 16
    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.

Revision history for this message
Robert Collins (lifeless) wrote :

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.