Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-119102: Fix REPL for dumb terminal#119269

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 1 commit intopython:mainfromvstinner:pyrepl_dumb
May 21, 2024

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedMay 20, 2024
edited by bedevere-appbot
Loading

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.

@vstinner
Copy link
MemberAuthor

cc@pablogamboa@ambv

Lib/site.py Outdated
try:
if os.getenv("PYTHON_BASIC_REPL"):
if os.getenv("PYTHON_BASIC_REPL") or not _pyrepl._CAN_USE_PYREPL:
Copy link
Contributor

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 theexcept block in__main__ when we have adumb 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

Copy link
MemberAuthor

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.

@vstinner
Copy link
MemberAuthor

@ambv: Do you have an idea on how to fix mypy?

@eugenetriguba
Copy link
Contributor

eugenetriguba commentedMay 21, 2024
edited
Loading

@vstinnerUsingfrom . import _CAN_USE_PYREPL instead ofimport _pyrepl seems to work. Not sure if there is a better solution It seems to work in that it makes mypy happy, but it wouldn't allow updating the variable in the other module 🙂

@vstinner
Copy link
MemberAuthor

@vstinner Using from . import _CAN_USE_PYREPL instead of import _pyrepl seems to work.

In that case,_CAN_USE_PYREPL = False only sets the variable in__main__.py, not in__init__.py.

Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decideif _pyrepl.write_history_file() can be used.
@vstinner
Copy link
MemberAuthor

I rewrote the fix to please the typing gods.

@vstinnervstinner merged commit73f4a58 intopython:mainMay 21, 2024
@vstinnervstinner deleted the pyrepl_dumb branchMay 21, 2024 12:53
@vstinnervstinner added the needs backport to 3.13bugs and security fixes labelMay 21, 2024
@miss-islington-app
Copy link

Thanks@vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 21, 2024
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decideif _pyrepl.write_history_file() can be used.(cherry picked from commit73f4a58)Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

GH-119308 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelMay 21, 2024
vstinner added a commit that referenced this pull requestMay 21, 2024
gh-119102: Fix REPL for dumb terminal (GH-119269)Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decideif _pyrepl.write_history_file() can be used.(cherry picked from commit73f4a58)Co-authored-by: Victor Stinner <vstinner@python.org>
@danielhollas
Copy link
Contributor

I rewrote the fix to please the typing gods.

@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 likefrom _pyrepl.__main__ import CAN_USE_PYREPL re-executes the code in__main__, and thereforeCAN_USE_PYREPL will always beTrue on non-windows systems.

@lysnikolaou
Copy link
Member

Same behavior for me that@danielhollas described.

@vstinner
Copy link
MemberAuthor

Sorry, I didn't retest functionally after fixing mypy 😬

@vstinner
Copy link
MemberAuthor

Please check my second fix: PRgh-119332.

@ambvambv added the topic-replRelated to the interactive shell labelMay 23, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decideif _pyrepl.write_history_file() can be used.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@eugenetrigubaeugenetrigubaeugenetriguba left review comments

@pablogsalpablogsalpablogsal approved these changes

Assignees
No one assigned
Labels
skip newstopic-replRelated to the interactive shell
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@vstinner@eugenetriguba@danielhollas@lysnikolaou@pablogsal@ambv

[8]ページ先頭

©2009-2025 Movatter.jp