-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-119102: Fix REPL for dumb terminal #119269
Conversation
Lib/site.py
Outdated
try: | ||
if os.getenv("PYTHON_BASIC_REPL"): | ||
if os.getenv("PYTHON_BASIC_REPL") or not _pyrepl._CAN_USE_PYREPL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: This is working, I presume, because we're hitting the except
block in __main__
when we have a dumb
TERM setting? I was initially a bit confused because I wasn't seeing why an extra conditional on a setting for a win32 check would fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_pyrepl._CAN_USE_PYREPL
is set to False if pyrepl fails at startup.
@ambv: Do you have an idea on how to fix mypy? |
@vstinner |
In that case, |
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide if _pyrepl.write_history_file() can be used.
I rewrote the fix to please the typing gods. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide if _pyrepl.write_history_file() can be used. (cherry picked from commit 73f4a58) Co-authored-by: Victor Stinner <vstinner@python.org>
GH-119308 is a backport of this pull request to the 3.13 branch. |
@vstinner the new version doesn't seem to fix the issue for me (tested on Fedora 39). I've ran into the same problem when I was trying to fix this. It looks like |
Same behavior for me that @danielhollas described. |
Sorry, I didn't retest functionally after fixing mypy 😬 |
Please check my second fix: PR gh-119332. |
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide if _pyrepl.write_history_file() can be used.
Move CAN_USE_PYREPL variable from _pyrepl.main to _pyrepl and rename it to _CAN_USE_PYREPL. Use the variable in the site module to decide if _pyrepl.write_history_file() can be used.