-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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-32642: add support for path-like objects in sys.path #32118
bpo-32642: add support for path-like objects in sys.path #32118
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). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Could you add a test please? The existing test doesn't exercise the code changes. |
The sys.path did only accept `str` or `bytes` object. This change makes `os.PathLike` object to be accepted as well.
194b978
to
a8c5f54
Compare
@@ -24,13 +25,12 @@ def remove_modules(self): | |||
del sys.modules[module_name] | |||
|
|||
def setUp(self): | |||
self.test_dir = tempfile.mkdtemp() | |||
self.test_dir = pathlib.Path(tempfile.mkdtemp()) |
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.
this removes the test for str on sys.path
@@ -1475,7 +1475,10 @@ def _get_spec(cls, fullname, path, target=None): | |||
# the list of paths that will become its __path__ | |||
namespace_path = [] | |||
for entry in path: | |||
if not isinstance(entry, str): | |||
try: | |||
# bytes, str and path-like objects will pass 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.
you need to add a test for bytes on sys.path
, and test it with the other import systems. Note these tests fail with a BytesWarning
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.
cc @brettcannon
@noamcohen97 the issue for this was closed - #76823 (comment) you should raise the request on discuss https://discuss.python.org/c/ideas/6 |
Suggesting then to close this PR. |
The sys.path did only accept
str
orbytes
object. This changemakes
os.PathLike
object to be accepted as well.https://bugs.python.org/issue32642