[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-08 Thread Stefan Krah

Stefan Krah added the comment:

Thanks, Amaury. Should be fixed now.

--
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9a701e8ec2c9 by Stefan Krah in branch '3.3':
Issue #16431: Finally, consider all permutations.
http://hg.python.org/cpython/rev/9a701e8ec2c9

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-07 Thread Amaury Forgeot d'Arc

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
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7fcc58811e82 by Stefan Krah in branch '3.3':
Issue #16431: Also fix the opposite direction.
http://hg.python.org/cpython/rev/7fcc58811e82

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1b6c972457e6 by Stefan Krah in branch '3.3':
Issue #16431: Use the type information when constructing a Decimal subtype
http://hg.python.org/cpython/rev/1b6c972457e6

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-07 Thread Yury Selivanov

Changes by Yury Selivanov :


--
nosy: +yselivanov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-07 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16431] CDecimal disregards subclass passed into __new__ when value argument is an instance of Decimal

2012-11-07 Thread Elvis Pranskevichus

New submission from Elvis Pranskevichus:

Consider the following:

import decimal

class MyDecimal(decimal.Decimal):
def __new__(cls, value):
return super().__new__(cls, value)

a = decimal.Decimal('1.0')
b = MyDecimal(a)
c = MyDecimal('1.0')

print(type(a), type(b), isinstance(b, MyDecimal), type(c), isinstance(c, 
MyDecimal))

Running the above in 3.3 produces:

  False  True

Which shows that Decimal.__new__(cls, Decimal()) will always return its 
argument regardless of cls.

--
messages: 175121
nosy: Elvis.Pranskevichus, skrah
priority: normal
severity: normal
status: open
title: CDecimal disregards subclass passed into __new__ when value argument is 
an instance of Decimal
type: behavior
versions: Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com