classification
Title: SystemError in bytes.__rmod__
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: 26766 Superseder:
Assigned To: serhiy.storchaka Nosy List: ethan.furman, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2016-04-15 07:28 by serhiy.storchaka, last changed 2016-04-16 08:22 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
bytes_rmod.patch serhiy.storchaka, 2016-04-15 07:28 review
Messages (6)
msg263457 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-04-15 07:28
>>> [] % 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.
msg263460 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-04-15 08:53
bytes_rmod.patch LGTM (maybe just a minor PEP 7 issue, see my review).
msg263468 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-04-15 10:24
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?
msg263472 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-15 11:14
New changeset ebece99c0bb6 by Serhiy Storchaka in branch 'default':
Issue #26764: Fixed SystemError in bytes.__rmod__.
https://hg.python.org/cpython/rev/ebece99c0bb6

New changeset 8dee0c09b46e by Serhiy Storchaka in branch '3.5':
Issue #26764: Bacported tests for bytes formatting.
https://hg.python.org/cpython/rev/8dee0c09b46e
msg263484 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-04-15 12:07
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'>
msg263487 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-04-15 12:30
There is a bug in bytearray formatting. See issue26766.
History
Date User Action Args
2016-04-16 08:22:33serhiy.storchakasetstatus: open -> closed
resolution: fixed
2016-04-15 12:30:01serhiy.storchakasetdependencies: + The result type of bytearray formatting is not stable
messages: + msg263487
2016-04-15 12:07:33vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg263484
2016-04-15 11:38:33serhiy.storchakasetstatus: open -> closed
assignee: serhiy.storchaka
stage: patch review -> resolved
resolution: fixed
versions: - Python 3.5
2016-04-15 11:14:44python-devsetnosy: + python-dev
messages: + msg263472
2016-04-15 10:24:45serhiy.storchakasetmessages: + msg263468
2016-04-15 08:53:32vstinnersetnosy: + vstinner
messages: + msg263460
2016-04-15 07:28:02serhiy.storchakacreate