Skip to content

Commit 787ab24

Browse files
committedDec 20, 2017
in case student's files shadow packages
1 parent f9a239b commit 787ab24

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎setup.py

Lines changed: 1 addition & 1 deletion
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.3.2"
19+
version="2.3.3"
2020
)

‎src/cs50/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
import os
12
import sys
23

4+
# Save student's sys.path
5+
path = sys.path[:]
6+
7+
# In case student has files that shadow packages
8+
sys.path = [p for p in sys.path if p not in ("", os.getcwd())]
9+
10+
# Import cs50_*
311
from .cs50 import eprint, get_char, get_float, get_int, get_string
412
try:
513
from .cs50 import get_long
614
except:
715
pass
816

17+
# Monkey patches
918
from . import flask
1019

1120

@@ -32,3 +41,7 @@ def load_module(self, name):
3241

3342

3443
sys.meta_path.append(CustomImporter())
44+
45+
46+
# Restore student's sys.path
47+
sys.path = path

0 commit comments

Comments
 (0)
Please sign in to comment.