Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grays out site packages in tracebacks #33

Merged
merged 13 commits into from
Nov 1, 2017
Prev Previous commit
Next Next commit
adding support for virtualenvs, which don't support site.getsitepackages
dmalan committed Oct 29, 2017
commit 466559262364a388863d9d4fadc67f8604789ed3
6 changes: 4 additions & 2 deletions src/cs50/cs50.py
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@
import re
import sys

from distutils.sysconfig import get_python_lib
from os.path import abspath, join
from site import getsitepackages, getusersitepackages
from site import getusersitepackages
from termcolor import cprint
from traceback import extract_tb, format_list, format_exception_only

@@ -16,8 +17,9 @@ def excepthook(type, value, tb):
and user-specific site-packages directory.
https://stackoverflow.com/a/33042323/5156190
https://stackoverflow.com/a/122340/5156190
"""
packages = tuple(join(abspath(p), "") for p in getsitepackages() + [getusersitepackages()])
packages = tuple(join(abspath(p), "") for p in [get_python_lib(), getusersitepackages()])
for entry in extract_tb(tb):
fmt = format_list((entry,))
if (entry[0].startswith(packages)):