zopefoundation / zExceptions

zExceptions contains common exceptions used in Zope.
Other
0 stars 5 forks source link

pypy and python 3 compatibility #1

Closed davisagli closed 9 years ago

davisagli commented 9 years ago

This adds configuration for running tests with tox, and compatibility with PyPy and Python 3.

The biggest change here is to the __str__ and __unicode__ methods of the Unauthorized exception. __str__ used to return either bytes or unicode depending on the exception argument types (because of implicit conversion), and then __unicode__ would try to decode as ascii if necessary, sometimes resulting in a UnicodeDecodeError (and there were tests for this). Now the canonical implementation is moved to __unicode__ (aliased to __str__ on python 3) which decodes the exception arguments as utf-8 if necessary and returns unicode. That value is then encoded by __str__ on python 2 and __bytes__ on python 3.

tseaver commented 9 years ago

Wow, great job!