-
Notifications
You must be signed in to change notification settings - Fork 771
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
Pylance crashes when parsing large integers #2279
Comments
One of the shortest valid Python source I found to reproduce this bug is just this literal (A single literal on a line is valid Python): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff The number is >>> float(2 ** 1024 - 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: int too large to convert to float The overflow explains why the number is being erroneously converted to the floating point infinity in the stack trace. This bug impacts cryptographic Python scripts or modules that frequently use huge integers as constants. |
One ugly workaround is to wrap the big number literals |
This bug should've been introduced very recently, because when I wrote this code, a few weeks ago, it didn't fail. I guess it must've been introduced in the past week or so |
Thanks for reporting, and sorry for the regression. In the past week, I added support for large integers. But it appears that there are limits beyond which the implementation fails. My test cases tested very large numbers but not very very very large numbers. I'm working on a fix now. |
This will be fixed in the next release. |
This issue was fixed in version 2022.1.5. You can find the changelog here: CHANGELOG.md |
Environment data
Expected behaviour
Pylance should correctly parse large integers
Actual behaviour
Pylance crashes when parsing big integers, stating "RangeError: The number Infinity cannot be converted to a BigInt because it is not an integer"
Logs
Code Snippet / Additional information
The text was updated successfully, but these errors were encountered: