Skip to content

Commit 85b0ae0

Browse files
author
Kareem Zidane
authored
Merge pull request #147 from cs50/develop
v6.0.3
2 parents dd789d6 + aee3be0 commit 85b0ae0

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
package_dir={"": "src"},
1717
packages=["cs50"],
1818
url="https://github.com/cs50/python-cs50",
19-
version="6.0.2"
19+
version="6.0.3"
2020
)

src/cs50/cs50.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,11 @@ def get_string(prompt):
133133
Read a line of text from standard input and return it as a string,
134134
sans trailing line ending. Supports CR (\r), LF (\n), and CRLF (\r\n)
135135
as line endings. If user inputs only a line ending, returns "", not None.
136-
Returns None upon error or no input whatsoever (i.e., just EOF). Exits
137-
from Python altogether on SIGINT.
136+
Returns None upon error or no input whatsoever (i.e., just EOF).
138137
"""
138+
if type(prompt) is not str:
139+
raise TypeError("prompt must be of type str")
139140
try:
140-
if prompt is not None:
141-
print(prompt, end="")
142-
s = sys.stdin.readline()
143-
if not s:
144-
return None
145-
return re.sub(r"(?:\r|\r\n|\n)$", "", s)
146-
except KeyboardInterrupt:
147-
sys.exit("")
148-
except ValueError:
141+
return input(prompt)
142+
except EOFError:
149143
return None

0 commit comments

Comments
 (0)