Differences between revisions 2 and 5 (spanning 3 versions)
Revision 2 as of 2011-03-23 01:45:32
Size: 961
Comment:
Revision 5 as of 2018-07-25 19:48:22
Size: 0
Editor: chapoton
Comment: useless and disturbing
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
matplotlib's experiences porting to Python 3.

* 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