Skip to content

Commit

Permalink
Merge pull request #147 from cs50/develop
Browse files Browse the repository at this point in the history
v6.0.3
  • Loading branch information
Kareem Zidane authored Mar 10, 2021
2 parents dd789d6 + aee3be0 commit 85b0ae0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
package_dir={"": "src"},
packages=["cs50"],
url="https://github.com/cs50/python-cs50",
version="6.0.2"
version="6.0.3"
)
16 changes: 5 additions & 11 deletions src/cs50/cs50.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,11 @@ def get_string(prompt):
Read a line of text from standard input and return it as a string,
sans trailing line ending. Supports CR (\r), LF (\n), and CRLF (\r\n)
as line endings. If user inputs only a line ending, returns "", not None.
Returns None upon error or no input whatsoever (i.e., just EOF). Exits
from Python altogether on SIGINT.
Returns None upon error or no input whatsoever (i.e., just EOF).
"""
if type(prompt) is not str:
raise TypeError("prompt must be of type str")
try:
if prompt is not None:
print(prompt, end="")
s = sys.stdin.readline()
if not s:
return None
return re.sub(r"(?:\r|\r\n|\n)$", "", s)
except KeyboardInterrupt:
sys.exit("")
except ValueError:
return input(prompt)
except EOFError:
return None

0 comments on commit 85b0ae0

Please sign in to comment.