Skip to content

Commit d731c45

Browse files
author
Kareem Zidane
authored
Merge pull request #67 from cs50/develop
2019 version
2 parents 5a89ecb + 242442d commit d731c45

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
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.4.4"
19+
version="3.0.0"
2020
)

src/cs50/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
sys.path = [p for p in sys.path if p not in ("", os.getcwd())]
1111

1212
# Import cs50_*
13-
from .cs50 import eprint, get_char, get_float, get_int, get_string
13+
from .cs50 import get_char, get_float, get_int, get_string
1414
try:
1515
from .cs50 import get_long
1616
except ImportError:

src/cs50/cs50.py

-12
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,6 @@ def read(self, size):
5353
sys.stdout = flushfile(sys.stdout)
5454

5555

56-
def eprint(*args, **kwargs):
57-
"""
58-
Print an error message to standard error, prefixing it with
59-
file name and line number from which method was called.
60-
"""
61-
end = kwargs.get("end", "\n")
62-
sep = kwargs.get("sep", " ")
63-
(filename, lineno) = inspect.stack()[1][1:3]
64-
print("{}:{}: ".format(filename, lineno), end="")
65-
print(*args, end=end, file=sys.stderr, sep=sep)
66-
67-
6856
def formatException(type, value, tb):
6957
"""
7058
Format traceback, darkening entries from global site-packages directories

src/cs50/sql.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,18 @@ def _parse(self, e):
8787
return str(e)
8888

8989
def execute(self, text, **params):
90-
"""
91-
Execute a SQL statement.
92-
"""
90+
"""Execute a SQL statement."""
91+
9392
class UserDefinedType(sqlalchemy.TypeDecorator):
94-
"""
95-
Add support for expandable values, a la https://bitbucket.org/zzzeek/sqlalchemy/issues/3953/expanding-parameter.
96-
"""
93+
"""Add support for expandable values, a la https://github.com/sqlalchemy/sqlalchemy/issues/3953."""
9794

95+
# Required class-level attribute
96+
# https://docs.sqlalchemy.org/en/latest/core/custom_types.html#sqlalchemy.types.TypeDecorator
9897
impl = sqlalchemy.types.UserDefinedType
9998

10099
def process_literal_param(self, value, dialect):
101100
"""Receive a literal parameter value to be rendered inline within a statement."""
101+
102102
def process(value):
103103
"""Render a literal value, escaping as needed."""
104104

@@ -147,8 +147,7 @@ def process(value):
147147
else:
148148
return process(value)
149149

150-
# Allow only one statement at a time
151-
# SQLite does not support executing many statements
150+
# Allow only one statement at a time, since SQLite doesn't support multiple
152151
# https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.execute
153152
if len(sqlparse.split(text)) > 1:
154153
raise RuntimeError("too many statements at once")
@@ -234,10 +233,10 @@ def process(value):
234233
def _connect(dbapi_connection, connection_record):
235234
"""Enables foreign key support."""
236235

237-
# Ensure backend is sqlite
236+
# If back end is sqlite
238237
if type(dbapi_connection) is sqlite3.Connection:
239-
cursor = dbapi_connection.cursor()
240238

241239
# Respect foreign key constraints by default
240+
cursor = dbapi_connection.cursor()
242241
cursor.execute("PRAGMA foreign_keys=ON")
243242
cursor.close()

0 commit comments

Comments
 (0)