changeset: 100038:c873a479a6a3 user: Victor Stinner date: Fri Jan 22 12:22:07 2016 +0100 files: Lib/site.py Misc/NEWS description: 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 -r 0f46c9a5735f -r c873a479a6a3 Lib/site.py --- a/Lib/site.py Thu Jan 21 22:04:04 2016 -0800 +++ b/Lib/site.py Fri Jan 22 12:22:07 2016 +0100 @@ -504,9 +504,13 @@ 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 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 -r 0f46c9a5735f -r c873a479a6a3 Misc/NEWS --- a/Misc/NEWS Thu Jan 21 22:04:04 2016 -0800 +++ b/Misc/NEWS Fri Jan 22 12:22:07 2016 +0100 @@ -146,6 +146,10 @@ 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.