Skip to content
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-120221: Deliver real singals on Ctrl-C and Ctrl-Z in the new REPL #120354

Merged
merged 2 commits into from
Jun 11, 2024

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jun 11, 2024

@pablogsal
Copy link
Member Author

@lysnikolaou Unfortunately I have not found a proper way to test this since it requires a terminal that sends something on Ctrl-C (sending signals won't test that we are not intercepting ourselves Ctrl-C neither will do it writing manually Ctrl-C to the REPL because that will never arrive if this is done properly), so this needs to be manually tested. Do you mind confirming that it works on your side?

@pablogsal
Copy link
Member Author

Check #120221 (comment) for a reproducer

@lysnikolaou
Copy link
Contributor

This works for me! Only weird thing is that it adds some kind of weird indentation when pressing Ctrl-C more times.

❯ ./python.exe
Python 3.14.0a0 (heads/paste:4e170a4361b, Jun 11 2024, 19:04:57) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import signal
>>> signal.signal(signal.SIGINT,\040lambda\040*x:\040print("NOOOO"))KeyboardInterrupt
>>> signal.signal(signal.SIGINT, lambda *x: print("NOOOO"))
<built-in function default_int_handler>
>>> NOOOO
         NOOOO
              NOOOO
                   NOOOO
                        NOOOO
                             NOOOO

@pablogsal
Copy link
Member Author

pablogsal commented Jun 11, 2024

This works for me! Only weird thing is that it adds some kind of weird indentation when pressing Ctrl-C more times.

Yeah, but I think is because it's printing in the middle of REPL code and not informing the reader (that's expected).

@pablogsal pablogsal merged commit 34e4d32 into python:main Jun 11, 2024
41 checks passed
@pablogsal pablogsal deleted the paste branch June 11, 2024 19:20
@miss-islington-app
Copy link

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 11, 2024
… REPL (pythonGH-120354)

(cherry picked from commit 34e4d32)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jun 11, 2024

GH-120368 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 11, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants