Skip to content

Commit bcdf95a

Browse files
committed
fix check rule
1 parent cd08e68 commit bcdf95a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/getpass.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def unix_getpass(prompt='Password: ', stream=None, *, echochar=None):
4343
4444
Always restores terminal settings before returning.
4545
"""
46-
if _is_ascii(echochar):
46+
if not _is_ascii(echochar):
4747
return ValueError(f"'echochar' must be ASCII, got: {echochar!r}")
4848

4949
passwd = None
@@ -109,7 +109,7 @@ def win_getpass(prompt='Password: ', stream=None, *, echochar=None):
109109
"""Prompt for password with echo off, using Windows getwch()."""
110110
if sys.stdin is not sys.__stdin__:
111111
return fallback_getpass(prompt, stream)
112-
if _is_ascii(echochar):
112+
if not _is_ascii(echochar):
113113
return ValueError(f"'echochar' must be ASCII, got: {echochar!r}")
114114

115115
for c in prompt:
@@ -148,9 +148,9 @@ def fallback_getpass(prompt='Password: ', stream=None):
148148

149149
def _is_ascii(echochar):
150150
# ASCII excluding control characters
151-
if echochar and not (32 <= ord(echochar) <= 127):
152-
return False
153-
return True
151+
if echochar and (32 <= ord(echochar) <= 127):
152+
return True
153+
return False
154154

155155

156156
def _raw_input(prompt="", stream=None, input=None):

0 commit comments

Comments
 (0)