From: Victor Stinner Date: Fri, 22 Jan 2016 11:22:07 +0000 (+0100) Subject: site: error on sitecustomize import error X-Git-Tag: v3.6.0a1~717 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3560a7dc9eeac324ff407588cb3f0b36ffe5c6e;p=python 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. --- diff --git a/Lib/site.py b/Lib/site.py index 3a8d1c3728..13ec8fa43f 100644 --- a/Lib/site.py +++ b/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()) diff --git a/Misc/NEWS b/Misc/NEWS index 01e933c460..4e3cc96f54 100644 --- a/Misc/NEWS +++ b/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.