matplotlib's experiences porting to Python 3.
* Drop support for < 2.6 (master currently supports 2.4)
* Easy things (that 2to3 handles pretty well):
- print function
- "in" vs. "has_key"
- "except Exception as exc" syntax
- stdlib stuff
* 2to3 is slooooow
* Unicode
- Unicode literals by default
- no implicit conversion between Unicode and bytes (encoding must be explicit)
- files must have explicit Unicode encoding, or be binary -- hard to do both at same time
* Exceptions
exceptions_found = []
try:
do_something()
except Exception as e:
exceptions_found.append(e)Since e now has a traceback member, this creates a cycle e -> traceback -> current stack frame -> e. This cycle will keep alive all local variables in all frames beneath the source of the exception.
* C/C++ issues
- For us, mostly hidden by using CXX
PyCObject was dropped in Python 3.2 -- had to port CXX to use its replacement PyCapsule