[issue46866] bytes class extension with slices

2022-02-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Yes, it is consistent with all of builtin types. If you want to return a 
different type, override __getitem__().

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46866] bytes class extension with slices

2022-02-26 Thread Sec


New submission from Sec :

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  as expected.

But x[1:].__class__ returns 

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

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com