Skip to content

Conversation

@chriso
Copy link
Contributor

@chriso chriso commented Mar 25, 2024

This PR adds support for Python 3.10.

Versions prior to 3.11 have an additional stack of "blocks" on each frame that need to be persisted. We now store this information along with a "block pointer" so that we can later restore the frame properly.

In 703f1e8, I changed the extension so that it's more verbose when it comes to handling the differences across Python versions. Previously we were using macros with range checks, and aliasing fields that had the same structure but used different names across versions. Given the divergence in frame structures across Python 3.10 and 3.11, I felt it was better to be explicit and verbose when dealing with differences across versions. There'll now be a block of #if PY_MINOR_VERSION == N ... #elif PY_MINOR_VERSION == N+1 ... #elif PY_MINOR_VERSION == N+2 ... #endif each time something changes across versions, and there'll be a block for each version that we support. This should make it easier to add support for more versions (e.g. 3.9) and also deprecate versions in future.

This fixes #42.

chriso added 16 commits March 25, 2024 10:21
Avoid range checks on PY_MINOR_VERSION. These get
confusing the more that structs diverge across versions.
Avoid aliasing struct fields across Python versions too.

Instead, when structs/enums/accessors/mutators diverge
across Python versions, use an explicit chain of
branch contains the full copy of the struct/enum at
that version, or the code required to access/mutate
a struct field.

This should hopefully clear up the code as support
for new versions are added, and reduce coding errors
over time.
@chriso chriso marked this pull request as ready for review March 27, 2024 01:04
@chriso chriso self-assigned this Mar 27, 2024
@chriso chriso requested a review from achille-roussel March 27, 2024 02:15
Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

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

I like the refactor into multiple files, so much easier to read and it establishes a good structure to continue maintaining this code for future Python versions 👏

@chriso chriso merged commit 0f09f42 into main Mar 27, 2024
@chriso chriso deleted the py310 branch March 27, 2024 02:20
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.

Add support for Python 3.10

2 participants