Comment 0 for bug 1473688

Revision history for this message
Jason Gerard DeRose (jderose) wrote : Update unit tests for Python 3.5 support

Python 3.5 makes some changes in the exact TypeError messages used when it comes to the Python Buffer Protocol.

Specifically for Dbase32, the TypeError messages will differ on Python 3.4 vs 3.5 when the "y#" and "s#" formats are used with PyArg_ParseTuple() and PyArg_ParseTupleAndKeywords(), which effects 4 of the 6 dbase32 functions:

dbase32.db32enc()
dbase32.db32dec()
dbase32.isdb32()
dbase32.check_db32()

For example, Python 3.4:

>>> from dbase32 import db32dec
>>> db32dec(76)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' does not support the buffer interface

Vs Python 3.5:

>>> from dbase32 import db32dec
>>> db32dec(76)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'int'

So the Dbase32 unit tests need to be updated to test against the new TypeError message format for Python >= 3.5, while still also being able to test against the old TypeError format for Python < 3.5, as Python 3.4 support isn't being dropped. (Actually, Dbase32 should still be compatible with Python 3.3 as well, but that's not actively tested by me anymore, so YMMV.)

A small update is also needed in the pure-Python _dbase32py.py fallback/reference implementation as it emulates the TypeError behaviour of the "y#" and "s#" C formats.