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.__new__ doesn't subclass
Type: behavior Stage:
Components: Interpreter Core, Library (Lib) Versions: Python 3.1
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, kaizhu, lasko
Priority: normal Keywords:

Created on 2009-09-08 01:56 by kaizhu, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg92406 - (view) Author: kai zhu (kaizhu) Date: 2009-09-08 01:56
# a00.py

parent = bytearray # fails
# parent = bytes   # works
# parent = str     # works

class Foo(parent):

  def __new__(klass, x): return parent.__new__(klass, x)

Foo(x = None)



$ python3.1 -c "import a00"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "a00.py", line 11, in <module>
    Foo(x = None)
TypeError: 'x' is an invalid keyword argument for this function
lethe 3 /tmp/kaizhu/Python-3.1.1:
msg92407 - (view) Author: Brandon Height (lasko) Date: 2009-09-08 02:06
This behavior is also found inside of version 2.6.2
msg92408 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-09-08 02:16
That's because bytearray is mutable, so it uses __init__ instead of __new__.
History
Date User Action Args
2022-04-11 14:56:52adminsetgithub: 51110
2009-09-08 02:16:03benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg92408

resolution: not a bug
2009-09-08 02:06:50laskosetnosy: + lasko
messages: + msg92407
2009-09-08 01:56:14kaizhucreate