Amaury Forgeot d'Arc added the comment:

"Py_INCREF(v); return v;" should be used only for immutable types, not for 
subclasses. in 3.2, the code below prints "3, None":

import decimal
class MyDecimal(decimal.Decimal):
    x = None
    def __new__(cls, value):
        return super().__new__(cls, value)
        return obj
a = MyDecimal("1.1")
a.x = 3
b = MyDecimal(a)
print(a.x, b.x)

nosy: +amaury.forgeotdarc

Python tracker <>
Python-bugs-list mailing list

Reply via email to