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
6 changes: 2 additions & 4 deletions src/cs50/cs50.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@

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

@@ -16,10 +15,9 @@ def excepthook(type, value, tb):
Format traceback, darkening entries from global site-packages directories
and user-specific site-packages directory.
https://stackoverflow.com/a/33042323/5156190
https://stackoverflow.com/a/122340/5156190
https://stackoverflow.com/a/46071447/5156190
"""
packages = tuple(join(abspath(p), "") for p in [get_python_lib(), getusersitepackages()])
packages = tuple(join(abspath(p), "") for p in sys.path[1:])
for entry in extract_tb(tb):
fmt = format_list((entry,))
if (entry[0].startswith(packages)):