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

The repr of ctypes.CArgObject fails for non-ascii character #79565

Closed
serhiy-storchaka opened this issue Dec 3, 2018 · 4 comments
Closed

The repr of ctypes.CArgObject fails for non-ascii character #79565

serhiy-storchaka opened this issue Dec 3, 2018 · 4 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes extension-modules C modules in the Modules dir topic-ctypes type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 35384
Nosy @amauryfa, @abalkin, @meadori, @serhiy-storchaka, @miss-islington
PRs
  • bpo-35384: The repr of ctypes.CArgObject no longer fail for non-ascii character. #10863
  • [3.7] bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863) #10983
  • [3.6] bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863) #10984
  • [3.7] bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863) #10985
  • 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 = None
    closed_at = <Date 2018-12-06.10:07:10.580>
    created_at = <Date 2018-12-03.10:52:28.429>
    labels = ['extension-modules', '3.8', 'ctypes', 'type-bug', '3.7']
    title = 'The repr of ctypes.CArgObject fails for non-ascii character'
    updated_at = <Date 2018-12-06.10:07:10.579>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-12-06.10:07:10.579>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-12-06.10:07:10.580>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules', 'ctypes']
    creation = <Date 2018-12-03.10:52:28.429>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35384
    keywords = ['patch']
    message_count = 4.0
    messages = ['330931', '331213', '331215', '331219']
    nosy_count = 5.0
    nosy_names = ['amaury.forgeotdarc', 'belopolsky', 'meador.inge', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['10863', '10983', '10984', '10985']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35384'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    The repr of the ctypes.CArgObject instance will fail when the value is a non-ascii character.

    The code is:

        sprintf(buffer, "<cparam '%c' (%c)>",
            self->tag, self->value.c);
    ...
    return PyUnicode_FromString(buffer);
    

    If self->value.c is out of range 0-127, buffer will contain a string not decodable with UTF-8.

    There is a similar problem with non-ascii self->tag.

    The following PR is purposed to fix this, but I don't know how to test it. Current tests only create CArgObject instances with tag='P' (in byref()).

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes extension-modules C modules in the Modules dir topic-ctypes type-bug An unexpected behavior, bug, or error labels Dec 3, 2018
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 3ffa8b9 by Serhiy Storchaka in branch 'master':
    bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863)
    3ffa8b9

    @miss-islington
    Copy link
    Contributor

    New changeset f9d8b68 by Miss Islington (bot) in branch '3.6':
    bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863)
    f9d8b68

    @miss-islington
    Copy link
    Contributor

    New changeset f740818 by Miss Islington (bot) in branch '3.7':
    bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863)
    f740818

    @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
    Labels
    3.7 (EOL) end of life 3.8 only security fixes extension-modules C modules in the Modules dir topic-ctypes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants