Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-41109: subclasses of pathlib.Path and pathlib.PurePath now call the subclass's __init__() and __new__() functions when returning new objects#21920

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

Closed
websurfer5 wants to merge22 commits intopython:mainfromwebsurfer5:fix-issue-41109

Conversation

@websurfer5
Copy link
Contributor

@websurfer5websurfer5 commentedAug 19, 2020
edited by bedevere-bot
Loading

Several pathlib.Path and pathlib.PurePath return new Path and PurePath objects. A subclass of one of those classes returns objects that are instances of the subclass, but the subclass'snew() andinit() functions are not called. A subclass has to override Path._init() or PurePath._init() to perform custom initialization for these returned objects in addition to itsinit() function.

This patch reworks the Path and PurePath object creation processes to ensure that thenew() andinit() functions in subclasses get called. It moves the object creation process from PurePath._from_parts() and PurePath._from_parsed_parts() to PurePath.init() and Path.init(), and marks the two functions with deprecation warnings.

https://bugs.python.org/issue41109

…bles and properties from __new__() object creation
@terryjreedy
Copy link
Member

@barneygale Does#102789 supersede this? (Should this be closed?)

@barneygale
Copy link
Contributor

@barneygale Does#102789 supersede this? (Should this be closed?)

Yes you're right it does, thanks!

@websurfer5 thanks for your work on this. We came to a similar solution in the end by the looks of things!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@websurfer5@terryjreedy@barneygale@brettcannon@the-knights-who-say-ni@ezio-melotti@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp