Skip to content

Incompatibility with CPython for bytearray.__repr__ #8311

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

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 newcomers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions