Browse Source

site: error on sitecustomize import error

Issue #26099: The site module now writes an error into stderr if sitecustomize
module can be imported but executing the module raise an ImportError. Same
change for usercustomize.
pull/9921/head
Victor Stinner 11 years ago
parent
commit
e3560a7dc9
  1. 20
      Lib/site.py
  2. 4
      Misc/NEWS

20
Lib/site.py

@ -504,9 +504,13 @@ def venv(known_paths):
def execsitecustomize():
"""Run custom site specific code, if available."""
try:
import sitecustomize
except ImportError:
pass
try:
import sitecustomize
except ImportError as exc:
if exc.name == 'sitecustomize':
pass
else:
raise
except Exception as err:
if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info())
@ -520,9 +524,13 @@ def execsitecustomize():
def execusercustomize():
"""Run custom user specific code, if available."""
try:
import usercustomize
except ImportError:
pass
try:
import usercustomize
except ImportError as exc:
if exc.name == 'usercustomize':
pass
else:
raise
except Exception as err:
if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info())

4
Misc/NEWS

@ -146,6 +146,10 @@ Core and Builtins
Library
-------
- Issue #26099: The site module now writes an error into stderr if
sitecustomize module can be imported but executing the module raise an
ImportError. Same change for usercustomize.
- Issue #26147: xmlrpc now works with strings not encodable with used
non-UTF-8 encoding.

Loading…
Cancel
Save