Skip to content

Commit 3c027d4

Browse files
committed
Add handle of new cases
1 parent 59da53c commit 3c027d4

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,6 @@ getopt
608608
(Contributed by Serhiy Storchaka in :gh:`126390`.)
609609

610610

611-
graphlib
612-
--------
613-
614-
* Allow :meth:`graphlib.TopologicalSorter.prepare` to be called more than once
615-
as long as sorting has not started.
616-
(Contributed by Daniel Pope in :gh:`130914`)
617-
618-
619611
getpass
620612
-------
621613

@@ -625,6 +617,14 @@ getpass
625617
(Contributed by Semyon Moroz in :gh:`77065`.)
626618

627619

620+
graphlib
621+
--------
622+
623+
* Allow :meth:`graphlib.TopologicalSorter.prepare` to be called more than once
624+
as long as sorting has not started.
625+
(Contributed by Daniel Pope in :gh:`130914`)
626+
627+
628628
http
629629
----
630630

Lib/getpass.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def fallback_getpass(prompt='Password: ', stream=None):
147147
def _check_echochar(echochar):
148148
# ASCII excluding control characters
149149
if echochar and not (echochar.isprintable() and echochar.isascii()):
150-
raise ValueError(f"'echochar' must be ASCII, got: {echochar!r}")
150+
raise ValueError("'echochar' must be a printable ASCII string, "
151+
f"got: {echochar!r}")
151152

152153

153154
def _raw_input(prompt="", stream=None, input=None):
@@ -184,21 +185,30 @@ def _input_with_echochar(prompt, stream, input, echochar):
184185
stream.write(prompt)
185186
stream.flush()
186187
passwd = ""
188+
eof_pressed = False
187189
while True:
188190
char = input.read(1)
189191
if char == '\n' or char == '\r':
190192
break
191-
if char == '\x03':
193+
elif char == '\x03':
192194
raise KeyboardInterrupt
193-
if char == '\x7f' or char == '\b':
195+
elif char == '\x7f' or char == '\b':
194196
if passwd:
195197
stream.write("\b \b")
196198
stream.flush()
197199
passwd = passwd[:-1]
200+
elif char == '\x04':
201+
if eof_pressed:
202+
break
203+
else:
204+
eof_pressed = True
205+
elif char == '\x00':
206+
continue
198207
else:
199208
passwd += char
200209
stream.write(echochar)
201210
stream.flush()
211+
eof_pressed = False
202212
return passwd
203213

204214

0 commit comments

Comments
 (0)