-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Py313 REPL crash on malformed os.environ
#128636
Comments
Thanks for the report.
It's a problem in the new PyREPL added in 3.13, the old one is okay: ❯ PYTHON_BASIC_REPL=1 python
Python 3.13.1 (v3.13.1:06714517797, Dec 3 2024, 14:00:22) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ = []
>>> https://docs.python.org/3/whatsnew/3.13.html#a-better-interactive-interpreter |
Similar thing happens when you do e.g.: >>> import os
>>> os.environ['LINES'] = '' |
So, that specific bug is within the new PyREPL. I see that. But Carreau hinted that a number of projects assume >>> import os
>>> os.environ = {}
Traceback (most recent call last):
...
Exception: environ and environb are protected variables; consider `.clear()`
>>> That's more controversial of course, but perhaps not without some merit. A thought. With that, I'll watch from the sidelines unless otherwise poked. Thanks! |
I don't think we need to make |
Bug description
While researching a personal project bug, I made a typo in the REPL. Obviously, one shouldn't do like the following distilled MRE, but a crash is a crash so reporting it:
This is clearly a PEBCAK interaction; the proper way to have cleared the environment would have been
.clear()
(and as an education point and/or reminder for search engine retrieval or others reading this later,os.environ
andos.environb
are "special" in that they're assumed to exist and are linked — a change to one affects the other).But, my late-night typo did produce an interpreter crash, so reporting here.
Note that this does not appear to fail in Python up to v3.12. Python 3.13 is the first to crash this way.
Background
I initially thought it was an IPython bug, and so reported it there. @Carreau rightly course-corrected me, with a suggestion for a possible upstream fix in CPython.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
os.environ
is overwritten with an invalid value #128653The text was updated successfully, but these errors were encountered: