Differences between revisions 2 and 3
Revision 2 as of 2011-03-23 01:45:32
Size: 961
Comment:
Revision 3 as of 2011-03-23 01:50:02
Size: 1021
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

* Drop support for < 2.6 (master currently supports 2.4)

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