New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decimal.py: minor issues && usability #51044
Comments
Hi, a couple of minor issues: 1:
>>> c = getcontext()
>>> c.traps[InvalidOperation] = False
>>> Decimal("NaN").__int__()
Decimal('NaN') I think the return value should be None. 2:
>>> c = getcontext()
>>> c.traps[InvalidOperation] = False
>>> Decimal("NaN").__long__()
Traceback (most recent call last):
...
RuntimeError: maximum recursion depth exceeded in cmp
3:
>>> setcontext(8)
>>> getcontext()
8 This is just a usability issue, perhaps a type check could be performed. |
Thanks for the reports. Issue 1. If this is going to be changed, I'd rather see Conversions from Decimal to native integers lie outside the scope of the Given the lack of guidance from the decimal standard, the next place to """When a NaN or infinite operand cannot be represented in the As far as I can tell, when the invalid-operation trap is disabled, the But in Python this error condition *can* 'otherwise be indicated', by Raymond, Facundo: any thoughts on this? Issue 2. A clear bug; will fix. Thanks. Issue 3. I can't see how this could cause any real problems, since you'd |
Issue 1: +1 to raise ValueError Issue 3: -0 to change actual behaviour Thanks! |
[...]
Excellent analysis, I would be very much in favour of this.
Agreed, it's not really important. |
Fixed __long__ bug and changed behaviour of int(Decimal('nan')) in r74708 |
On second thoughts, I'm going to call this a bug and backport to 2.6 and |
Fixed in r74719 (release26-maint), r74720 (release31-maint). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: