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

BytesWarning at compile time #73523

Closed
serhiy-storchaka opened this issue Jan 21, 2017 · 6 comments
Closed

BytesWarning at compile time #73523

serhiy-storchaka opened this issue Jan 21, 2017 · 6 comments
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 29337
Nosy @brettcannon, @vstinner, @methane, @serhiy-storchaka
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • constant-key-bytes-warning.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 = None
    closed_at = <Date 2017-01-24.18:55:22.284>
    created_at = <Date 2017-01-21.07:09:46.734>
    labels = ['interpreter-core', 'type-bug', '3.7']
    title = 'BytesWarning at compile time'
    updated_at = <Date 2017-03-31.16:36:17.714>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:17.714>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-01-24.18:55:22.284>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-01-21.07:09:46.734>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['46370']
    hgrepos = []
    issue_num = 29337
    keywords = ['patch']
    message_count = 6.0
    messages = ['285940', '285943', '286107', '286150', '286205', '286208']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'vstinner', 'methane', 'python-dev', 'serhiy.storchaka']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29337'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    BytesWarning can be raised during compilation.

    $ ./python -Wa -b -c "lambda: 'a'; lambda: b'a'"
    sys:1: BytesWarning: Comparison between bytes and string
    sys:1: BytesWarning: Comparison between bytes and string
    sys:1: BytesWarning: Comparison between bytes and string
    sys:1: BytesWarning: Comparison between bytes and string

    _PyCode_ConstantKey() should produce keys that don't allow comparing bytes with strings nested in tuples or frozensets. Currently it returns (tuple, ('a',), ((str, 'a'),)) for ('a',) and (tuple, (b'a',), ((bytes, b'a'),)) for (b'a',). Key tuples have the same size and the same first element. Comparing second elements emits a BytesWarning.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jan 21, 2017
    @serhiy-storchaka
    Copy link
    Member Author

    Proposed patch fixes the issue.

    @brettcannon
    Copy link
    Member

    LGTM

    1 similar comment
    @methane
    Copy link
    Member

    methane commented Jan 24, 2017

    LGTM

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 24, 2017

    New changeset 2bd2ef1696cf by Serhiy Storchaka in branch '3.5':
    Issue bpo-29337: Fixed possible BytesWarning when compare the code objects.
    https://hg.python.org/cpython/rev/2bd2ef1696cf

    New changeset f6c327f2daa6 by Serhiy Storchaka in branch '3.6':
    Issue bpo-29337: Fixed possible BytesWarning when compare the code objects.
    https://hg.python.org/cpython/rev/f6c327f2daa6

    New changeset 00fb30d4905d by Serhiy Storchaka in branch 'default':
    Issue bpo-29337: Fixed possible BytesWarning when compare the code objects.
    https://hg.python.org/cpython/rev/00fb30d4905d

    @vstinner
    Copy link
    Member

    I'm surprised that removing the type from the key works. Since tests pass,
    it's ok for me :-)

    I'm happy that I spent time to write these tests, I'm now more confident
    when this code is modified. Serhiy asked me to write these tests if I
    recall correctly ;-)

    @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 interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants