Skip to content

[3.6] bpo-30167: Prevent site.main() exception if PYTHONSTARTUP is set. (GH-6731)#7607

Merged
ned-deily merged 1 commit into
python:3.6from
miss-islington:backport-2487f30-3.6
Jun 11, 2018
Merged

[3.6] bpo-30167: Prevent site.main() exception if PYTHONSTARTUP is set. (GH-6731)#7607
ned-deily merged 1 commit into
python:3.6from
miss-islington:backport-2487f30-3.6

Conversation

@miss-islington

@miss-islington miss-islington commented Jun 11, 2018

Copy link
Copy Markdown
Contributor

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.
(cherry picked from commit 2487f30)

Co-authored-by: Steve Weber steverweber@gmail.com

https://bugs.python.org/issue30167

…thonGH-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.
(cherry picked from commit 2487f30)

Co-authored-by: Steve Weber <steverweber@gmail.com>
@miss-islington

Copy link
Copy Markdown
Contributor Author

@steverweber and @ned-deily: Backport status check is done, and it's a success ✅ .

@ned-deily ned-deily merged commit 3e12158 into python:3.6 Jun 11, 2018
@miss-islington

Copy link
Copy Markdown
Contributor Author

Thanks, @ned-deily!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants