Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
GH-76846, GH-85281: Call__new__() and__init__() on pathlib subclasses#102789
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
LGTM (with what I marked). Any concerns in particular that you'd like me to take a closer look at?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I think those were my only areas of concern! Thanks for the review :) |
Are you happy for me to merge,@zooba? |
All yours |
…pathlib subclasses (pythonGH-102789)Fix an issue where `__new__()` and `__init__()` were not called on subclasses of `pathlib.PurePath` and `Path` in some circumstances.Paths are now normalized on-demand. This speeds up path construction, `p.joinpath(q)`, and `p / q`.Co-authored-by: Steve Dower <steve.dower@microsoft.com>
…pathlib subclasses (pythonGH-102789)Fix an issue where `__new__()` and `__init__()` were not called on subclasses of `pathlib.PurePath` and `Path` in some circumstances.Paths are now normalized on-demand. This speeds up path construction, `p.joinpath(q)`, and `p / q`.Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Uh oh!
There was an error while loading.Please reload this page.
This PR fixes an issue where
__new__()and__init__()were not called on subclasses ofpathlib.PurePathandPathin some circumstances.Specifically, the
_from_parsed_parts()constructor -- which is used when iterating directories, parents, and inwith_name()and friends -- has been altered as follows:This change alone has an unfortunate effect: paths constructed this way are re-parsed and re-normalized even though we have the fully normalized path at hand.
To fix this, we change the main constructor tonot normalize paths. Instead, paths are normalized on-demand. This also speeds up path construction,
p.joinpath(q), andp / q.