This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bytearray.fromhex doesn't respect bytearray subclass
Type: behavior Stage:
Components: Versions: Python 3.0
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, pitrou
Priority: normal Keywords:

Created on 2008-12-06 14:56 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg77130 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-12-06 14:56
The following code says it all:

>>> class B(bytearray): pass
... 
>>> b = B.fromhex("0c0a")
>>> b
bytearray(b'\x0c\n')
>>> isinstance(b, B)
False
msg77139 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-12-06 15:53
The same kind of request has been rejected several times: issue2267, 
issue1562.

The explanation given is here:
http://mail.python.org/pipermail/python-list/2005-January/300791.html
"""a base class has no idea what requirements may exist for invoking a 
subclass's constructor"""
History
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48814
2008-12-06 15:53:57amaury.forgeotdarcsetstatus: open -> closed
resolution: wont fix
messages: + msg77139
nosy: + amaury.forgeotdarc
2008-12-06 14:56:43pitroucreate