-
Notifications
8000
You must be signed in to change notification settings - Fork 87
Incompatible (with int) parsing of the sign in the mpz constructor #381
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
Comments
Another example:
BTW, base=0 is incompatible with the int's base=10 default. |
Python and GMP handle embedded white space differently. They both ignore leading and trailing white space. But Python considers embedded white space an error while GMP ignores embedded white space. The general rule is that gmpy2 should always return the same result as Python if no exception is raised by Python. Raising an exception when Python doesn't is a bug. Returning a "reasonable" value when Python raises an exception is acceptable (at least it is to me). I think striping all white space is fine and matches the current behavior. But we won't match the Python exceptions for I also prefer the default of base=0. It is easier for converting strings that include the leading base indicators. |
Sure, that was the rule I kept in mind.
Probably, this does make sense for all constructors.
My fault. That difference does matter only where Python raises exceptions (e.g. `int('0x10')). |
gmpy2 has fix for aleaxit/gmpy#381 only in the development version, so I have added simple workaround for this.
gmpy2 has fix for aleaxit/gmpy#381 only in the development version, so I have added simple workaround for this.
gmpy2 has fix for aleaxit/gmpy#381 only in the development version, so I have added simple workaround for this.
while
"Optionally, the string can be preceded by + or - (with no space in between), have leading zeros, be surrounded by whitespace, and have single underscores interspersed between digits." (c) CPython docs
The text was updated successfully, but these errors were encountered: