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

Update int range detection for Python 3 #603

Merged
merged 3 commits into from
Feb 14, 2021

Conversation

bryan-koroleski-fivestars
Copy link
Contributor

@bryan-koroleski-fivestars bryan-koroleski-fivestars commented Jan 21, 2021

The type checks in javascript_bindings.pyx and process_message_utils.pyx currently only work in Python 2. Python 3 unified int and long into a single arbitrarily sized int type. The end result is that these checks fail to detect integers larger than 32-bits. This change:

  • Exposes INT_MIN and INT_MAX from limits.h
  • Updates the int range check to work with both Python 2 and Python 3
  • Preserves the behavior of attempting to set properties containing integers outside of the 32-bit int range

I've run the tests and examples on Win10 with Python 3.8.6 32-bit and can confirm this change works as expected.

Python 3 unified ints and longs into a single int type. The long type
is still available in Cython as an alias to int.
return True
if INT_MIN <= value <= INT_MAX:
return True
return "long"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like bug. This won't allow long values inside nested structures.

@cztomczak cztomczak merged commit 054ff3c into cztomczak:master Feb 14, 2021
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