Commit e3560a7d authored by Victor Stinner's avatar Victor Stinner

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.
parent ae8c078d
...@@ -504,9 +504,13 @@ def venv(known_paths): ...@@ -504,9 +504,13 @@ def venv(known_paths):
def execsitecustomize(): def execsitecustomize():
"""Run custom site specific code, if available.""" """Run custom site specific code, if available."""
try: try:
import sitecustomize try:
except ImportError: import sitecustomize
pass except ImportError as exc:
if exc.name == 'sitecustomize':
pass
else:
raise
except Exception as err: except Exception as err:
if os.environ.get("PYTHONVERBOSE"): if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info()) sys.excepthook(*sys.exc_info())
...@@ -520,9 +524,13 @@ def execsitecustomize(): ...@@ -520,9 +524,13 @@ def execsitecustomize():
def execusercustomize(): def execusercustomize():
"""Run custom user specific code, if available.""" """Run custom user specific code, if available."""
try: try:
import usercustomize try:
except ImportError: import usercustomize
pass except ImportError as exc:
if exc.name == 'usercustomize':
pass
else:
raise
except Exception as err: except Exception as err:
if os.environ.get("PYTHONVERBOSE"): if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info()) sys.excepthook(*sys.exc_info())
......
...@@ -146,6 +146,10 @@ Core and Builtins ...@@ -146,6 +146,10 @@ Core and Builtins
Library 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 - Issue #26147: xmlrpc now works with strings not encodable with used
non-UTF-8 encoding. non-UTF-8 encoding.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment