-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-30167: site: Ignore TypeError in abs_paths() #6731
Conversation
https://bugs.python.org/issue30167 change in the behavior of "os.path.abspath(None)". Before Python 3.6, used to report an AttributeError which is properly caught inside "site.abs_paths", making it ignore __main__, one of sys.modules, which has __file__ and __cached__ set to None.
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. When your account is ready, please add a comment in this pull request Thanks again to your contribution and we look forward to looking at it! |
CLA signed yesterday and today. perhaps bot bugged. |
@@ -108,7 +108,7 @@ def abs_paths(): | |||
pass | |||
try: | |||
m.__cached__ = os.path.abspath(m.__cached__) | |||
except (AttributeError, OSError): | |||
except (AttributeError, OSError, TypeError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't line-107 need catching TypeError too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps it should... However since file seems to be set in most cases it wont cause a TypeError.
Thanks for your contribution, @steverweber. The fix should include a test (In Lib/test/test_site.py) that demonstrates that the problem is fixed and so we don't break it again in the future. |
Thanks @steverweber for the PR, and @ned-deily for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
GH-7606 is a backport of this pull request to the 3.7 branch. |
…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 <[email protected]>
GH-7607 is a backport of this pull request to the 3.6 branch. |
…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 <[email protected]>
…-6731) (GH-7606) 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 <[email protected]>
…-6731) (GH-7607) 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 <[email protected]>
Behavior of "os.path.abspath(None)" was changed.
Before Python 3.6, used to report an AttributeError which is properly caught inside "site.abs_paths", making it ignore
__main__
, one of sys.modules, which has__file__
and__cached__
set to None.perhaps best to find what sets
__cache__
as None and /fix/ that instead of this proposed fix.https://bugs.python.org/issue30167