File tree 2 files changed +6
-12
lines changed
2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change 16
16
package_dir = {"" : "src" },
17
17
packages = ["cs50" ],
18
18
url = "https://github.com/cs50/python-cs50" ,
19
- version = "6.0.2 "
19
+ version = "6.0.3 "
20
20
)
Original file line number Diff line number Diff line change @@ -133,17 +133,11 @@ def get_string(prompt):
133
133
Read a line of text from standard input and return it as a string,
134
134
sans trailing line ending. Supports CR (\r ), LF (\n ), and CRLF (\r \n )
135
135
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).
138
137
"""
138
+ if type (prompt ) is not str :
139
+ raise TypeError ("prompt must be of type str" )
139
140
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 :
149
143
return None
You can’t perform that action at this time.
0 commit comments