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-46927: Prevent readline from overriding environment#133585

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

Open
mbriand wants to merge7 commits intopython:main
base:main
Choose a base branch
Loading
frommbriand:fix-issue-46927

Conversation

mbriand
Copy link

@mbriandmbriand commentedMay 7, 2025
edited by bedevere-appbot
Loading

Readline library will set the LINES and COLUMNS environment variables during initialization. One might expect these variables to be updated later on SIGWINCH, but this is not the case with cpython.

As a consequence, when the readline module is imported, any process launched from cpython with the default environment will have LINES and COLUMNS variables set, potentially to a wrong value.

Use the rl_change_environment global variable to disable this initial setup of the environment variables.

@python-cla-bot
Copy link

python-cla-botbot commentedMay 7, 2025
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

Readline library will set the LINES and COLUMNS environment variablesduring initialization. One might expect these variables to be updatedlater on SIGWINCH, but this is not the case with cpython.As a consequence, when the readline module is imported, any processlaunched from cpython with the default environment will have LINES andCOLUMNS variables set, potentially to a wrong value.Use the rl_change_environment global variable to disable this initialsetup of the environment variables.
@@ -1323,6 +1323,13 @@ setup_readline(readlinestate *mod_state)
/* The name must be defined before initialization */
rl_readline_name = "python";

#if !defined(__APPLE__)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm a bit surprised I had to rely on the__APPLE__ define here. As I understand apple OS is using libedit, so I would have thought relying onWITH_EDITLINE would be enough. But the macOS pipeline proved me wrong...

Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add a test case. The file you're looking for istest_readline.

@@ -405,6 +407,12 @@ def test_write_read_limited_history(self):
# So, we've only tested that the read did not fail.
# See TestHistoryManipulation for the full test.

@requires_subprocess()
def test_environment_is_not_modified(self):
original_env = dict(os.environ)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Did you forget to add the use ofsubprocess here? This test always passes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Err sorry, I reworked the test and forgot to remove the subprocess requirement.

But I do confirm this test fails if I revert the initial commit of the PR.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ZeroIntensityZeroIntensityAwaiting requested review from ZeroIntensity

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@mbriand@ZeroIntensity

[8]ページ先頭

©2009-2025 Movatter.jp