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 3.13.0b1: exec() does not populate locals() #118888
Comments
Bisected to b034f14 |
This is an expected and intentional behavior change due to PEP 667. I won't even consider this is "breaking" as the docs clearly states:
So this is an illegal usage that happens to work in a favored way to begin with. If you want the result of the local changes, pass in an explicit dictionary: def get_version():
version_file = "src/PIL/_version.py"
d = {}
with open(version_file, encoding="utf-8") as f:
exec(compile(f.read(), version_file, "exec"), globals(), d)
return d["__version__"] I'm aware that this might be a bit inconvenience to the library maintainers, but this is the right way to go and we are making efforts to make |
It it true that the 3.12 docs say that readx.py should not be expected to work. But it did then and previously, even though not now. What's New 3.13 only says
From this, I would not expect changes in how locals() behaves, in particular in the effect of exec bindings. I think this should be mention. Even the Python subsection of the PEP's Back Compatibility section says nothing. It only mentions a couple of things that do not change. |
We are aware that the docs are not fully ready for beta 1, but this behavior is described in detail in |
Bug report
Bug description:
x.py
readx.py
shell
This breaks e.g. pillow 10.3.0 which has:
In https://github.com/python-pillow/Pillow/blob/10.3.0/setup.py#L23
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: