[New-bugs-announce] [issue16722] __index__() overrides __bytes__() when bytes() is called

Руслан Ижбулатов report at bugs.python.org
Wed Dec 19 06:42:52 CET 2012


New submission from Руслан Ижбулатов:

If a class implements both __index__() and __bytes__(), the built-in bytes() constructor uses __index__() in place of __bytes__(), including the assumption that __index__() returns a bytes object.

Attaching a simple example (leads to overflow when big integer is casted to bytes).

----------
components: None
files: testb.py
messages: 177725
nosy: LRN
priority: normal
severity: normal
status: open
title: __index__() overrides __bytes__() when bytes() is called
versions: Python 3.3
Added file: http://bugs.python.org/file28357/testb.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16722>
_______________________________________


More information about the New-bugs-announce mailing list