-
-
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-39659: Route calls from pathlib.Path to os.getcwd() via the path accessor #18834
bpo-39659: Route calls from pathlib.Path to os.getcwd() via the path accessor #18834
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! |
This change should have no functional effect beyond the addition of |
@@ -1099,7 +1101,7 @@ def cwd(cls): | |||
"""Return a new path pointing to the current working directory | |||
(as returned by os.getcwd()). | |||
""" | |||
return cls(os.getcwd()) | |||
return cls(cls()._accessor.getcwd()) |
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 is a quirky way to implement it. If the accessor becomes tied to the class rather than specific instances, perhaps it should become a class-level attribute?
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's very similar to how home()
is implemented immediately below.
Agree generally that the accessor should be a class attribute and not an instance attribute.
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.
I've replaced cls()
with cls
in this method, and home()
for consistency.
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.
Well, that didn't work at all! Looks like:
_accessor
is set in_init()
, at least until bpo-40038: pathlib: remove partial support for preserving accessor when modifying a path #19342 lands_flavour
is set in__new__()
.
Reverting to previous patch (the one you reviewed).
cfc20dc
to
05e73d0
Compare
@barneygale This one looks like the conflict is meaningful? (And it's new because I merged one of your other changes, I think) |
05e73d0
to
74abd98
Compare
Thank you! Rebased :-) |
(from the bug description:) Whereas most calls to
os
functions frompathlib.Path
methods happen viapathlib._Accessor
methods, retrieving the current working directory does not. This problem occurs when calling thepathlib.Path.cwd()
,~resolve()
and~absolute()
methods.https://bugs.python.org/issue39659