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-134210: handle signals in_curses.window.getch#134326

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
picnixz merged 6 commits intopython:mainfrompicnixz:fix/curses/getch-signals-134210
May 27, 2025

Conversation

picnixz
Copy link
Member

@picnixzpicnixz commentedMay 20, 2025
edited by bedevere-appbot
Loading

@vstinner
Copy link
Member

vstinner commentedMay 20, 2025
edited
Loading

I tried this change with the script:

fromcursesimportwrapperimportctypesdefmain(window):window.nodelay(True)returnwindow.getch()print(wrapper(main))

Before (without this change), it displays-1.

After (with this change), it fails with the exception:_curses.error: wgetch() (called by getch()): no input.

So this change is backward incompatible. Is it deliberate?

@picnixz
Copy link
MemberAuthor

picnixz commentedMay 20, 2025
edited
Loading

Hum. No it's not meant to be broken!

Only the signals should be handled, but otherwise we shouldn't raise an exception.

@picnixz
Copy link
MemberAuthor

picnixz commentedMay 20, 2025
edited
Loading

Now I am bit conflicted. Ideally, we should return -1 for everythingor raise an exception as in the other functions. I don't know why it was historically chosen to return -1 forgetch but not forget_wch in no-delay mode.

However, since I don't want to break stuff, I don't know how we can make a smooth transition, except by raising a warning before returning -1.

@picnixz
Copy link
MemberAuthor

For now, let's keep the same behavior (namely, -1 forgetch, and exception forget_wch andgetkey). The functions have been there at least since Python 3.4 and I prefer not to change anything unless a more pressing issue exists. At least, signal handlers will be properly called.

@picnixzpicnixz requested a review fromvstinnerMay 24, 2025 11:12
@picnixz
Copy link
MemberAuthor

picnixz commentedMay 24, 2025
edited
Loading

I could backport this as it's half a bugfix and half a feature. I'll only backport this to 3.14 as the layout of 3.13 is very different for curses (there was a conversion from static types to heap types and I don't think it made it to 3.13)

@picnixzpicnixz requested a review fromvstinnerMay 25, 2025 12:53
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinner
Copy link
Member

You might backport the change to 3.13 and 3.14 bugfix branches.

@picnixzpicnixz self-assigned thisMay 26, 2025
@picnixzpicnixz merged commit51762b6 intopython:mainMay 27, 2025
39 checks passed
@picnixzpicnixz added the needs backport to 3.14bugs and security fixes labelMay 27, 2025
@miss-islington-app
Copy link

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

@picnixzpicnixz deleted the fix/curses/getch-signals-134210 branchMay 27, 2025 08:51
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 27, 2025
…34326)(cherry picked from commit51762b6)Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app
Copy link

GH-134783 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelMay 27, 2025
picnixz added a commit to picnixz/cpython that referenced this pull requestMay 27, 2025
…honGH-134326)(cherry picked from commit51762b6)Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app
Copy link

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

picnixz added a commit that referenced this pull requestMay 27, 2025
#134783)gh-134210: handle signals in `_curses.window.getch` (GH-134326)(cherry picked from commit51762b6)Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz added a commit that referenced this pull requestMay 27, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vstinnervstinnervstinner approved these changes

Assignees

@picnixzpicnixz

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@picnixz@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp