Uh oh!
There was an error while loading. Please reload this page.
gh-119102: Fix REPL for dumb terminal - #119269
Conversation
vstinner
commented
May 20, 2024
| import _pyrepl | ||
| 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.
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.
_pyrepl._CAN_USE_PYREPL is set to False if pyrepl fails at startup.
vstinner
commented
May 21, 2024
@ambv: Do you have an idea on how to fix mypy? |
@vstinner |
vstinner
commented
May 21, 2024
In that case, |
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide if _pyrepl.write_history_file() can be used.
vstinner
commented
May 21, 2024
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. |
danielhollas
commented
May 21, 2024
@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 |
lysnikolaou
commented
May 21, 2024
Same behavior for me that @danielhollas described. |
vstinner
commented
May 21, 2024
Sorry, I didn't retest functionally after fixing mypy 😬 |
vstinner
commented
May 21, 2024
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.