You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BTW, as a user, I'd expect Decimal.from_float to simply coerce its input to float if given an input that isn't actually a float in the first place; the fact that it has special handling in place for int inputs (and that that special handling takes the form of an isinstance check, rather than something more duck-typed) is surprising.
andrewnester commented on Feb 13, 2017
andrewnestermannequin
Mannequin
More actions
actually, it's more related to subclassing, because the problem comes from the fact that before the fix __init__ method receives value as int not Decimal if int passed to from_float call.
That's why only subclasses of Decimal can see difference in arguments received by __init__
andrewnester commented on Feb 13, 2017
andrewnestermannequin
Mannequin
More actions
Agree about surprising behaviour but I guess it's better to fix it as other issue because it could break BC in some cases. At least it needs to be investigated.
For now I would like to stick with same behaviour for _decimal and _pydecimal
No, it's better not to "fix" it at all. :-) It's one of those many behaviour changes where the answer to "Should we have done this differently in the first place" might possibly be "Yes" (and might also be "No"), but the answer to "Should we *change* it now" is a definite "No" (especially given that the "from_float" method is there almost entirely for backwards compatibility). I shouldn't have brought it up. Apologies.
andrewnester commented on Feb 13, 2017
andrewnestermannequin
Mannequin
More actions
thanks for your notes, it's absolutely fine and I agree with you :)
Unfortunately, just after I merged it I noticed that the Misc/NEWS entry was in the wrong section. I'll make a new PR to fix that, and close this issue once it's done.
Activity
arigo commentedon Feb 11, 2017
A difference in behavior between _decimal and _pydecimal (it seems that _decimal is more consistent in this case):
skrah commentedon Feb 11, 2017
I get the the same output, perhaps I misunderstand something here:
arigo commentedon Feb 11, 2017
Sorry! It should be repr(a) inside the print. Here is the fixed version:
andrewnester commentedon Feb 13, 2017
I've just added PR for this issue.
mdickinson commentedon Feb 13, 2017
Is there an observable difference in user behaviour if no subclassing of Decimal is involved? Or does this just affect Decimal subclasses?
mdickinson commentedon Feb 13, 2017
BTW, as a user, I'd expect
Decimal.from_floatto simply coerce its input to float if given an input that isn't actually a float in the first place; the fact that it has special handling in place for int inputs (and that that special handling takes the form of an isinstance check, rather than something more duck-typed) is surprising.andrewnester commentedon Feb 13, 2017
actually, it's more related to subclassing, because the problem comes from the fact that before the fix __init__ method receives value as int not Decimal if int passed to from_float call.
That's why only subclasses of Decimal can see difference in arguments received by __init__
andrewnester commentedon Feb 13, 2017
Agree about surprising behaviour but I guess it's better to fix it as other issue because it could break BC in some cases. At least it needs to be investigated.
For now I would like to stick with same behaviour for _decimal and _pydecimal
mdickinson commentedon Feb 13, 2017
[Andrew]
No, it's better not to "fix" it at all. :-) It's one of those many behaviour changes where the answer to "Should we have done this differently in the first place" might possibly be "Yes" (and might also be "No"), but the answer to "Should we *change* it now" is a definite "No" (especially given that the "from_float" method is there almost entirely for backwards compatibility). I shouldn't have brought it up. Apologies.
andrewnester commentedon Feb 13, 2017
thanks for your notes, it's absolutely fine and I agree with you :)
mdickinson commentedon Feb 14, 2017
PR merged; thank you!
Unfortunately, just after I merged it I noticed that the Misc/NEWS entry was in the wrong section. I'll make a new PR to fix that, and close this issue once it's done.
mdickinson commentedon Feb 14, 2017
PR to fix the Misc/NEWS entry: #99
mdickinson commentedon Feb 14, 2017
All done. Closing. (In theory, as a bugfix, this could be backported to 3.5 and 3.6. In practice, I doubt it's worth the effort.)
skrah commentedon Mar 31, 2017
Does anyone know how to disable the spurious pull requests that keep coming in?