Skip to content

Incompatibility with CPython for bytearray.__repr__ #8311

Closed

Description

@moreal

Feature

The result of repr(bytearray(b"\'")) doesn't match with CPython.

FAIL: test_bytearray_repr (test.test_bytes.AssortedBytesTest.test_bytearray_repr)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/path/to/RustPython/crates/pylib/Lib/test/test_bytes.py", line 2115, in test_bytearray_repr
    self.assertEqual(f(bytearray(b"'")), r'''bytearray(b"\'")''') # "\'"
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'bytearray(b"\'")' != 'bytearray(b"\\\'")'
- bytearray(b"'")
+ bytearray(b"\'")
?

Python Documentation or reference to CPython source code

TBD

Activity

  1. devyubin commented on Jul 18, 2026

    @devyubin
    Contributor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-compatA discrepancy between RustPython and CPythongood first issueGood for newcomersz-ca-2026Tag to track Contribution Academy 2026

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions