Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctypes: remove implicit conversion between unicode and bytes #53212

Closed
vstinner opened this issue Jun 10, 2010 · 4 comments
Closed

ctypes: remove implicit conversion between unicode and bytes #53212

vstinner opened this issue Jun 10, 2010 · 4 comments

Comments

@vstinner
Copy link
Member

BPO 8966
Nosy @theller, @vstinner, @florentx
Files
  • ctypes_conversion.patch
  • ctypes_s_set.patch
  • ctypes_tests-2.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/theller'
    closed_at = <Date 2010-07-28.00:22:40.553>
    created_at = <Date 2010-06-10.23:03:25.738>
    labels = ['ctypes', 'expert-unicode']
    title = 'ctypes: remove implicit conversion between unicode and bytes'
    updated_at = <Date 2010-07-28.00:22:40.475>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2010-07-28.00:22:40.475>
    actor = 'vstinner'
    assignee = 'theller'
    closed = True
    closed_date = <Date 2010-07-28.00:22:40.553>
    closer = 'vstinner'
    components = ['Unicode', 'ctypes']
    creation = <Date 2010-06-10.23:03:25.738>
    creator = 'vstinner'
    dependencies = []
    files = ['17611', '17612', '17634']
    hgrepos = []
    issue_num = 8966
    keywords = ['patch']
    message_count = 4.0
    messages = ['107499', '107590', '107591', '111750']
    nosy_count = 3.0
    nosy_names = ['theller', 'vstinner', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue8966'
    versions = ['Python 3.2']

    @vstinner
    Copy link
    Member Author

    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).

    @vstinner
    Copy link
    Member Author

    I commited ctypes_s_set.patch in Python 3.2 (r81911) because it does fix a real bug.

    @vstinner
    Copy link
    Member Author

    Update ctypes_tests.patch against last changes: ctypes_tests-2.patch.

    @vstinner
    Copy link
    Member Author

    I commited both patches to 3.2, but I splitted them in a different way:

    • r83191 "fixes" tests (remove implicit conversion)
    • r83195 removes the implicit conversion in ctypes

    So it's easier to review the commits and revert the second commit.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants