You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ctypes: remove implicit conversion between unicode and bytes #53212
ctypes doesn't have strict separation between bytes and characters, whereas Python3 splitted str/unicode of Python2 into bytes/str which a strict separation. The result is that sometimes it works (no error), sometimes it fails (the first time that the user inserts a non-ASCII character).
I wrote 3 patches:
ctypes_s_set.patch: fix s_set(), return an unicode string instead of a bytes string
ctypes_conversion.patch: remove ctypes.set_conversion_mode() and all code using it (remove the implicit conversions)
ctypes_tests.patch: fix all tests according the changes introduced by the two previous patches
ctypes_s_set.patch is trivial and fixes a real bug. ctypes_conversion.patch does basically remove code. ctypes_tests.patch is the biggest part because the test suite is mostly based on the implicit conversion.
Except the parts removing the calls to ctypes.set_conversion_mode() and the tests testing the implicit conversion, ctypes_tests.patch can be commited alone because it improves the test suite (use the right types).
Activity
vstinner commentedon Jun 10, 2010
ctypes doesn't have strict separation between bytes and characters, whereas Python3 splitted str/unicode of Python2 into bytes/str which a strict separation. The result is that sometimes it works (no error), sometimes it fails (the first time that the user inserts a non-ASCII character).
I wrote 3 patches:
ctypes_s_set.patch is trivial and fixes a real bug. ctypes_conversion.patch does basically remove code. ctypes_tests.patch is the biggest part because the test suite is mostly based on the implicit conversion.
Except the parts removing the calls to ctypes.set_conversion_mode() and the tests testing the implicit conversion, ctypes_tests.patch can be commited alone because it improves the test suite (use the right types).
vstinner commentedon Jun 11, 2010
I commited ctypes_s_set.patch in Python 3.2 (r81911) because it does fix a real bug.
vstinner commentedon Jun 11, 2010
Update ctypes_tests.patch against last changes: ctypes_tests-2.patch.
vstinner commentedon Jul 28, 2010
I commited both patches to 3.2, but I splitted them in a different way:
So it's easier to review the commits and revert the second commit.