Conversation
unix_getpass() disables ECHO but leaves the tty in canonical mode and calls readline(). A long pasted secret with no newline (a JWT is the usual case) can fill the kernel input queue (MAX_INPUT is 1024 on Darwin). Terminal.app writes the paste synchronously, so the UI wedges until the process is killed. Always switch the tty to non-canonical mode (VMIN=1, VTIME=0) and read byte-by-byte. Reuse the existing line editor so ERASE / KILL / INTR / EOF keep working when echo is off; only the echo_char drawing is skipped. readline() remains the fallback when the tty cannot be controlled. Fixes python#157538
|
@picnixz feedback plz on why? |
|
|
|
You should have posted on the issue first then, to mention that you worked on it. At least looking at the thread before. And I am still unsure about this fix. Switching to noncanonical had issues in the past (and thus I also wonder whether the problem is this specific change). So first we should diagnose the issue. |
|
@picnixz well this is some useful feedback. Thanks, I'll leave it to Adarsh-Me. Have a great day! |
|
@picnixz As previously mentioned in the issue I was able to reproduce, so we move past that. As per your request I ran an even deeper investigation into the history of the module not just a repro of the hang, so here's what we are working with:
The constraint from this whole history is the following:
Thus, in my opinion this does not need a new PR because this one is that exact change and strictly not a new tty design or a Darwin Please let me know what you think and whether you'd like me to adjust the PR text or tests to spell the history out if useful. |
unix_getpass()disablesECHObut leaves the tty in canonical mode and callsreadline(). A long pasted secret with no newline (a JWT is the usual case) can fill the kernel input queue (MAX_INPUTis 1024 on Darwin). Terminal.app writes the paste synchronously, so the UI wedges until the process is killed.Always switch the tty to non-canonical mode (
VMIN=1,VTIME=0) and read byte-by-byte. Reuse the existing line editor soERASE/KILL/INTR/EOFkeep working when echo is off; only theecho_chardrawing is skipped.readline()remains the fallback when the tty cannot be controlled.Fixes #157538