[issue46866] bytes class extension with slices
Sec
report at bugs.python.org
Sat Feb 26 06:37:49 EST 2022
New submission from Sec <sec at 42.org>:
When trying to extend the builtin bytes class, slices fall back to the builtin class.
```
class my_bytes(bytes):
def dummy(self):
print("dummy called")
x=my_bytes.fromhex("c0de c0de")
print(x.__class__)
print(x[1:].__class__)
```
x.__class__ returns <class '__main__.my_bytes'> as expected.
But x[1:].__class__ returns <class 'bytes'>
----------
components: Interpreter Core
files: bytes_test.py
messages: 414092
nosy: Sec42
priority: normal
severity: normal
status: open
title: bytes class extension with slices
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50646/bytes_test.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46866>
_______________________________________
More information about the Python-bugs-list
mailing list