|
|
|
|
|
by eesmith
804 days ago
|
|
I was not so lucky! I had a good test suite, but there were a lot of places where I mixed up strings and bytes. I had to add new parameters to specify in Unicode encoding/decoding options, new tests to handle those failures, and new APIs so I could have one function return bytes and another return strings. Plus, I had C extensions, which had to be updated to handle changes in the Python/C API, including places where Python 2.7 could handle both Unicode and bytes in the ASCII subset: >>> u"bbcf".decode("hex")
'\xbb\xcf'
>>> "bbcf".decode("hex")
'\xbb\xcf'
>>> b"bbcf".decode("hex")
'\xbb\xcf'
but under Python 3 required more work: >>> bytes.fromhex("BBCF")
b'\xbb\xcf'
>>> bytes.fromhex(b"BBCF")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: fromhex() argument must be str, not bytes
AND, I needed to support both Python 2.7 and Python 3.5+ on the same code base.AND, I needed to support various third-party tools that had their own different migration paths for how to handle the transition. |
|