-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Python] fix UInt.pythonObject for Python 3.7 #23055
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
[Python] fix UInt.pythonObject for Python 3.7 #23055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@swift-ci Please test tensorflow |
@turbolent |
@dan-zheng The existing unit tests already contain the necessary tests: https://github.com/apple/swift/blob/bc50eb5816162aee0b90e0cafb53266218332f71/test/Python/python_runtime.swift#L229-L233 I tried duplicating this test case and running it using Python 3.7, but it seems like subsequent calls to |
I added the fix also to PythonKit: pvieito/PythonKit#8, which tests only Python 3.7 |
Gotcha, thanks! Though the unit tests explicitly use Python 2.7, as you noted.
I believe the intended usage of Dynamically switching between Python versions in a program is not supported. It may be that we do not want to support this due to bad interactions between Python versions: for example, what happens if you perform operations on @pvieito: could you please confirm the behavior of |
Exactly. The first reference to the
Loading two versions of Switching Python versions (in the sense of unloading a Python library and loading other version) could be technically possible in some OS ( |
@dan-zheng @pvieito Thanks for the explanation, that makes sense! Is there any way to still have tests for both major versions? |
Duplicating the test file for both major versions would be straightforward, but we shouldn't do it because it's not maintainable. I think a good solution is to define all Python tests under a common Then, we can have two test files ( I filed TF-336 to track adding this unit test infra - it's a nice starter bug if you're interested. 🙂 |
For reference, I have hooked up a simple Travis CI on PythonKit that it simply launches the - PYTHON_VERSION=2 swift test
- PYTHON_VERSION=3 swift test Thanks to @turbolent for porting the tests to XCTest! 🙂 |
Fix
UInt.pythonObject
for Python 3.7. The existing conversion worked for Python 2.7, but crashed for 3.cc @pvieito @dan-zheng