[issue3630] Unable to inherit bytes: bytes.__init__() doesn't accept arguments

2008-08-21 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: With immutable types, you must use __new__ instead. Passing the arguments to __init__ is too late since the object is immutable and it has already been built in memory, thus you can't initialize it with another value. >>> class B(bytes): ...

[issue3630] Unable to inherit bytes: bytes.__init__() doesn't accept arguments

2008-08-21 Thread STINNER Victor
New submission from STINNER Victor <[EMAIL PROTECTED]>: Example: class MyBytes(bytes): def __init__(self, *args, **kw): bytes.__init__(self, *args, **kw) a = bytes(b"hello") # ok b = MyBytes(b"hello") # error => DeprecationWarning: object.__init__() takes no parameters