From: Fred Drake Date: Thu, 12 Jul 2001 21:08:33 +0000 (+0000) Subject: Actually remove directories from sys.path if they do not exist; the intent X-Git-Tag: v2.2a3~1239 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fd4ff52c2200078a6f55d85901c46fee83b1d420;p=thirdparty%2FPython%2Fcpython.git Actually remove directories from sys.path if they do not exist; the intent is to avoid as many stat() calls as we can. --- diff --git a/Lib/site.py b/Lib/site.py index 16540f6255a0..7848553122f3 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -79,6 +79,10 @@ del m L = [] dirs_in_sys_path = {} for dir in sys.path: + # Filter out paths that don't exist, but leave in the empty string + # since it's a special case. + if dir and not os.path.isdir(dir): + continue dir, dircase = makepath(dir) if not dirs_in_sys_path.has_key(dircase): L.append(dir)