Skip to content

Commit 13ddec0

Browse files
committedJul 9, 2017
exiting programs now on SIGINT a la C programs
1 parent 7e774d6 commit 13ddec0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
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="2.1.1"
19+
version="2.2.0"
2020
)

‎src/cs50/cs50.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def get_string(prompt=None):
117117
Read a line of text from standard input and return it as a string,
118118
sans trailing line ending. Supports CR (\r), LF (\n), and CRLF (\r\n)
119119
as line endings. If user inputs only a line ending, returns "", not None.
120-
Returns None upon error or no input whatsoever (i.e., just EOF).
120+
Returns None upon error or no input whatsoever (i.e., just EOF). Exits
121+
from Python altogether on SIGINT.
121122
"""
122123
try:
123124
if prompt is not None:
@@ -126,5 +127,7 @@ def get_string(prompt=None):
126127
if not s:
127128
return None
128129
return re.sub(r"(?:\r|\r\n|\n)$", "", s)
130+
except KeyboardInterrupt:
131+
sys.exit("")
129132
except ValueError:
130133
return None

0 commit comments

Comments
 (0)
Please sign in to comment.