diff options
author | Steve Weber <steverweber@gmail.com> | 2018-06-11 00:49:34 (GMT) |
---|---|---|
committer | Ned Deily <nad@python.org> | 2018-06-11 00:49:34 (GMT) |
commit | 2487f30d5529948ace26559e274d7cac6abcd1a8 (patch) | |
tree | fd1d6dda91a2988d54eb0cd89727646280435378 /Lib/site.py | |
parent | 8398713cea0eb17b013f25f86bef47c7e5e63139 (diff) | |
download | cpython-2487f30d5529948ace26559e274d7cac6abcd1a8.zip cpython-2487f30d5529948ace26559e274d7cac6abcd1a8.tar.gz cpython-2487f30d5529948ace26559e274d7cac6abcd1a8.tar.bz2 |
bpo-30167: Prevent site.main() exception if PYTHONSTARTUP is set. (GH-6731)
Before Python 3.6, os.path.abspath(None) used to report an AttributeError which was properly caught inside site.abs_paths, making it ignore __main__, one of sys.modules, which has __file__ and __cached__ set to None. With 3.6, os.path.abspath(None) raises TypeError instead which site.abs_path was not expecting. This resulted in an uncaught exception if a user had PYTHONSTARTUP set and the application called site.main() which a number of third-party programs do.
Diffstat (limited to 'Lib/site.py')
-rw-r--r-- | Lib/site.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/site.py b/Lib/site.py index 950e703..4595244 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -104,11 +104,11 @@ def abs_paths(): continue # don't mess with a PEP 302-supplied __file__ try: m.__file__ = os.path.abspath(m.__file__) - except (AttributeError, OSError): + except (AttributeError, OSError, TypeError): pass try: m.__cached__ = os.path.abspath(m.__cached__) - except (AttributeError, OSError): + except (AttributeError, OSError, TypeError): pass |