[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

[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