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

SystemError in bytes.__rmod__ #70951

Closed
serhiy-storchaka opened this issue Apr 15, 2016 · 6 comments
Closed

SystemError in bytes.__rmod__ #70951

serhiy-storchaka opened this issue Apr 15, 2016 · 6 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 26764
Nosy @vstinner, @ethanfurman, @serhiy-storchaka
Dependencies
  • bpo-26766: The result type of bytearray formatting is not stable
  • Files
  • bytes_rmod.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/serhiy-storchaka'
    closed_at = <Date 2016-04-16.08:22:33.689>
    created_at = <Date 2016-04-15.07:28:02.524>
    labels = ['interpreter-core', 'type-bug']
    title = 'SystemError in bytes.__rmod__'
    updated_at = <Date 2016-04-16.08:22:33.689>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-04-16.08:22:33.689>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-04-16.08:22:33.689>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-04-15.07:28:02.524>
    creator = 'serhiy.storchaka'
    dependencies = ['26766']
    files = ['42464']
    hgrepos = []
    issue_num = 26764
    keywords = ['patch']
    message_count = 6.0
    messages = ['263457', '263460', '263468', '263472', '263484', '263487']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'ethan.furman', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26764'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    >>> [] % b''
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    SystemError: Objects/bytesobject.c:2975: bad argument to internal function

    Proposed patch fixes bytes.__rmod__ and tests for bytes formatting.

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Apr 15, 2016
    @vstinner
    Copy link
    Member

    bytes_rmod.patch LGTM (maybe just a minor PEP-7 issue, see my review).

    @serhiy-storchaka
    Copy link
    Member Author

    Surprisingly the implementation in 3.5 is correct. But backporting tests exposed behavior change in bytearray formatting in 3.6. In 3.5 bytearray.__mod__ returns bytearray, in 3.6 it returns bytes. Is this intentional?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 15, 2016

    New changeset ebece99c0bb6 by Serhiy Storchaka in branch 'default':
    Issue bpo-26764: Fixed SystemError in bytes.__rmod__.
    https://hg.python.org/cpython/rev/ebece99c0bb6

    New changeset 8dee0c09b46e by Serhiy Storchaka in branch '3.5':
    Issue bpo-26764: Bacported tests for bytes formatting.
    https://hg.python.org/cpython/rev/8dee0c09b46e

    @vstinner
    Copy link
    Member

    Buildbots are unhappy.

    http://buildbot.python.org/all/builders/AMD64%20Debian%20root%203.x/builds/3456/steps/test/logs/stdio

    ======================================================================
    FAIL: test_imod (test.test_bytes.ByteArrayTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_bytes.py", line 507, in test_imod
        self.assertIs(type(b), bytes)
    AssertionError: <class 'bytearray'> is not <class 'bytes'>

    ======================================================================
    FAIL: test_mod (test.test_bytes.ByteArrayTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_bytes.py", line 495, in test_mod
        self.assertIs(type(a), bytes)
    AssertionError: <class 'bytearray'> is not <class 'bytes'>

    @vstinner vstinner reopened this Apr 15, 2016
    @serhiy-storchaka
    Copy link
    Member Author

    There is a bug in bytearray formatting. See bpo-26766.

    @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
    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

    2 participants