Skip to content

Make qpyson work with Python 3.13#2

Open
schragge wants to merge 1 commit into
mpkocher:masterfrom
schragge:schragge-patch-1
Open

Make qpyson work with Python 3.13#2
schragge wants to merge 1 commit into
mpkocher:masterfrom
schragge:schragge-patch-1

Conversation

@schragge

Copy link
Copy Markdown

Starting with Python 3.13, locals() has changed semantics when called in optimized scopes (in particular, it now always returns independent snapshots in such contexts, so that changing the values of local variables via exec() is being consistently ignored).

In contrast, frame.f_locals gives read/write access to the local variables in all scopes, including optimized scopes.

Replacing locals() with sys._getframe().f_locals inside an exec() call restores the old behavior.

Starting with Python 3.13, `locals()` has changed semantics when called in optimized scopes (in particular, it now always returns independent snapshots in such contexts, so that changing the values of local variables via `exec()` is being consistently ignored). 

In contrast, `frame.f_locals` gives read/write access to the local variables in all scopes, including optimized scopes.

Replacing `locals()` with `sys._getframe().f_locals` inside an `exec()` call restores the old behavior.
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.

1 participant