jpype-project / jpype

JPype is cross language bridge to allow Python programs full access to Java class libraries.
http://www.jpype.org
Apache License 2.0
1.12k stars 183 forks source link

Python 3.12 patch #1158

Closed Thrameos closed 11 months ago

Thrameos commented 11 months ago

This should fix Python 3.12 though not without serious wrinkles. The new PyLong mutates a field in such a way that it will break anything that wants to add memory to the tail of the object to save a few bytes. I though that given that we were following the exact mechanism that Python requires for its own structures that we would be safe. The mutation is entirely in private parts of Python so I can't just use the private symbols so we track with any changes. It doesn't just break our code but also the dictoffset and weakoffset fields in the Python base class, so I can't see that it will remain in the current state. Thus this is at best a version that will work until the repair to the memory model is done, and then we likely have to rework another time.

Changes include:

codecov[bot] commented 11 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (c11c3a2) 87.84% compared to head (b5c6083) 87.83%.

Files Patch % Lines
native/python/pyjp_module.cpp 0.00% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1158 +/- ## ========================================== - Coverage 87.84% 87.83% -0.02% ========================================== Files 112 112 Lines 10276 10283 +7 Branches 4032 4034 +2 ========================================== + Hits 9027 9032 +5 - Misses 698 699 +1 - Partials 551 552 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

marscher commented 11 months ago

Thanks again! This will make a lot of people happy I'd guess :+1:

pelson commented 11 months ago

Looks like it may be this change which started a Python 3.7 nightly test to fail. Example in https://gitlab.cern.ch/scripting-tools/pyjapc/-/jobs/34505253.

I'm pinned back right now, but can investigate later next week if needed.

Thrameos commented 11 months ago

Okay I can roll that back. I will have to investigate which systems have mallinfo vs mallinfo2.