GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-41109: subclasses of pathlib.Path and pathlib.PurePath now call the subclass's __init__() and __new__() functions when returning new objects by websurfer5 · Pull Request #21920 · python/cpython

Conversation

@websurfer5

@websurfer5 websurfer5 commented Aug 19, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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's new() and init() 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 its init() function.

This patch reworks the Path and PurePath object creation processes to ensure that the new() and init() 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
websurfer5 added 21 commits August 16, 2020 15:24
@websurfer5
bpo-41109: separate object creation by Path and PurePath member varia…
081cbc2
…bles and properties from __new__() object creation
@websurfer5
bpo-41109: Windows PurePath tests
0e4d53e
@websurfer5
bpo-41109: use correct class in PureWindowsSubclassNewAndInitTest
53643f4
@websurfer5
bpo-41109: fix comment
c418958
@websurfer5
bpo-41109: fix class names and comments
34683c4
@websurfer5
bpo-41109: WindowsPath test suite
19e0a40
@websurfer5
bpo-41109: add __init__() to Path and PurePath
1853c6d
@websurfer5
bpo-41109: remove extraneous **kwargs parameter from Path.__init__()
17c141c
@websurfer5
bpo-41109: remove extraneous whitespace
505cab0
@websurfer5
bpo-41109: remove double-initialization in Path.__new__()
c47bf06
@websurfer5
bpo-41109: no longer need to call _init() from PurePath.__init__()
6607e77
@websurfer5
bpo-41109: reorganize tests using a common base class for common tests
cf6afb0
@websurfer5
bpo-41109: fix readlink test for Windows
d25fdd7
@websurfer5
bpo-41109: cleanup test_resolve
4be7b7a
@websurfer5
bpo-41109: cleanup test_glob
1660fa6
@websurfer5
bpo-41109: test all initialization cases
2a27016
@websurfer5
bpo-41109: news blurb
4014a16
@websurfer5
bpo-41109: What's New entry and better news blurb
31b449e
@websurfer5
bpo-4119: Merge branch 'master' of github.com:python/cpython into fix…
ebc8371
…-issue-41109
@websurfer5
bpo-41109: improve What's New and News entries
86bb25b
@websurfer5
bpo-41109: simplify _new_from_parts() and _new_from_parsed_parts() in…
b2c62a6
… PurePath
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Aug 19, 2020
@bedevere-bot bedevere-bot added the awaiting review label Aug 19, 2020
@websurfer5
Merge branch 'master' of github.com:python/cpython into fix-issue-41109
6f363b9
@brettcannon brettcannon added the topic-pathlib label Jun 21, 2022
@conchylicultor conchylicultor mannequin mentioned this pull request Jun 21, 2022
subclasses of pathlib.PurePosixPath never call __init__ or __new__ #85281
Closed
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@terryjreedy

terryjreedy commented Apr 3, 2023

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale

barneygale commented Apr 3, 2023

Copy link
Copy Markdown
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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale barneygale closed this Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review topic-pathlib

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@websurfer5 @terryjreedy @barneygale @brettcannon @the-knights-who-say-ni @ezio-melotti @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.