From 7e774d6c2a3831ce42cabeb591e1f59c3e79876a Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sun, 9 Jul 2017 18:37:27 +0000 Subject: [PATCH 1/2] added ../src to path for tests --- tests/python2.py | 4 ++++ tests/python3.py | 4 ++++ tests/sqltests.py | 2 ++ 3 files changed, 10 insertions(+) diff --git a/tests/python2.py b/tests/python2.py index 69de822..c132c20 100644 --- a/tests/python2.py +++ b/tests/python2.py @@ -1,3 +1,7 @@ +import sys + +sys.path.insert(0, "../src") + import cs50 l = cs50.get_long() diff --git a/tests/python3.py b/tests/python3.py index b545b98..452b421 100644 --- a/tests/python3.py +++ b/tests/python3.py @@ -1,3 +1,7 @@ +import sys + +sys.path.insert(0, "../src") + import cs50 i = cs50.get_int() diff --git a/tests/sqltests.py b/tests/sqltests.py index c1f3c0e..c2af662 100644 --- a/tests/sqltests.py +++ b/tests/sqltests.py @@ -3,6 +3,8 @@ import unittest import warnings +sys.path.insert(0, "../src") + from cs50.sql import SQL class SQLTests(unittest.TestCase): From 13ddec011cd6fd117a3ab73a16d83cfa00780806 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sun, 9 Jul 2017 18:37:43 +0000 Subject: [PATCH 2/2] exiting programs now on SIGINT a la C programs --- setup.py | 2 +- src/cs50/cs50.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b4d078d..1c49faf 100644 --- a/setup.py +++ b/setup.py @@ -16,5 +16,5 @@ package_dir={"": "src"}, packages=["cs50"], url="https://github.com/cs50/python-cs50", - version="2.1.1" + version="2.2.0" ) diff --git a/src/cs50/cs50.py b/src/cs50/cs50.py index 5661aa9..b03cf04 100644 --- a/src/cs50/cs50.py +++ b/src/cs50/cs50.py @@ -117,7 +117,8 @@ def get_string(prompt=None): 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). + Returns None upon error or no input whatsoever (i.e., just EOF). Exits + from Python altogether on SIGINT. """ try: if prompt is not None: @@ -126,5 +127,7 @@ def get_string(prompt=None): if not s: return None return re.sub(r"(?:\r|\r\n|\n)$", "", s) + except KeyboardInterrupt: + sys.exit("") except ValueError: return None