Skip to content
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

Fix Long Numeric Integer representation for Python 3 #492

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

Levak
Copy link
Contributor

@Levak Levak commented Jun 21, 2024

Before Python 3, long integers were input with an L suffix. Since Python 3, all integers are 64-bit and do not need the L suffix.
Source: https://docs.python.org/3.0/whatsnew/3.0.html#integers

Scripts generated by pycdc from Python 3 that contained long numeric integers would not work on Python 3 because it always suffixed them with L.

Note: I am not sure how to adapt the test suite to reflect this.
Should I just add the .pyc file without changing test_integers.py ? That file was made with Python 2 in mind (e.g. print without parenthesis).
EDIT: Nvm, there is too many differences (e.g. sys.maxint was removed in Python 3).

@Levak
Copy link
Contributor Author

Levak commented Jun 21, 2024

Maybe we can change test_integers.py this way?

Python 3

$ echo 'print(24**24)' | python3 -m dis -
  1           0 LOAD_NAME                0 (print)
              2 LOAD_CONST               2 (1333735776850284124449081472843776)
              4 CALL_FUNCTION            1
              6 POP_TOP
              8 LOAD_CONST               1 (None)
             10 RETURN_VALUE

Python 2

$ echo 'print(24**24)' | python2.7 -m dis -
  1           0 LOAD_CONST               2 (1333735776850284124449081472843776L)
              3 PRINT_ITEM          
              4 PRINT_NEWLINE       
              5 LOAD_CONST               1 (None)
              8 RETURN_VALUE        

Before Python 3, long integers were input with an L suffix. Since
Python 3, all integers are 64-bit and do not need the L suffix.
@Levak Levak force-pushed the levak/fix_long_numeric branch from b3df9c9 to 2ae7f58 Compare June 22, 2024 21:19
@zrax zrax merged commit ed49554 into zrax:master Jun 23, 2024
5 checks passed
zrax added a commit that referenced this pull request Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants