-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-32642: Allow for PathLike objects in sys.path #22000
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
base: main
Are you sure you want to change the base?
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
ZackerySpytz
left a comment
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.
Please add tests.
I believe the documentation for sys.path should be updated.
| if not (isinstance(entry, (str, bytes)) or | ||
| hasattr(entry, '__fspath__')): |
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.
It seems that this change doesn't take the comment on the old PR into account.
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.
If you are talking about this comment.
I interpreted that discussion as " str and bytes could also be fed through _os.fspath ", which is what this PR does.
Do you have a different interpretation of that comment?
| @@ -0,0 +1 @@ | |||
| Add compatibility for path-like objects on sys.path. Patch by sroet | |||
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.
Markup could be used here.
:term:`path-like objects <path-like object>`:data:`sys.path`Please end sentences with periods.
As stated in the original comment:
Would you have any guidance on where the test file should live and how adding "files outside of the running directory" is commonly handled? |
This is similar to what was done in #5691, but that one seems abandoned.
It was mentioned there a test needed to be included.
My current idea of a test involves making files outside of the running directory to be added to sys.path and then imported.
I would like some guidance on what the best/common practices are for that in this code-base.
test that shows the issue (taken from issue32642):
t.pyin
foo/s.pyon master this gives:
With this implementation:
https://bugs.python.org/issue32642