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 — GH-100479: Add `pathlib.PurePath.with_segments()` by barneygale · Pull Request #103975 · python/cpython

Conversation

@barneygale

@barneygale barneygale commented Apr 28, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Add pathlib.PurePath.with_segments(), which creates a path object from arguments. This method is called whenever a derivative path is created, such as from pathlib.PurePath.parent. Subclasses may override this method to share information between path objects.

Alternative to #100481.

  • Issue: Support for sharing state between pathlib subclasses #100479

Sorry, something went wrong.

Uh oh!

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

All reactions
barneygale and others added 16 commits December 23, 2022 23:18
@barneygale
Add pathlib.PurePath.makepath(); unify path object construction
a6fdd0e
@barneygale
Fix reST role name.
b061747
@barneygale
Move call to os.getcwd() back into Path.cwd()
99eb8b1
@barneygale
Merge branch 'main' into pythongh-100479-add-makepath
4759d01
@barneygale
Merge branch 'main' into pythongh-100479-add-makepath
ef6f4c3
@barneygale
Add news blurb.
595b8ae
@barneygale
Merge branch 'main' into pythongh-100479-add-makepath
dcfe70a
@barneygale
Add whatsnew entry
117fe4b
@barneygale
Merge branch 'main' into pythongh-100479-add-makepath
e75dedc
@barneygale
Merge branch 'main' into pythongh-100479-add-makepath
5a6bd3f
@barneygale
other --> pathsegments
f2f1048
@barneygale @AlexWaygood
Update Lib/pathlib.py
3c172fb
Co-authored-by: Alex Waygood <[email protected]>
@barneygale
joinpath(*args) --> joinpath(*pathsegments)
4637109
@barneygale
Restore _PathParents
ae48454
@barneygale
Add note to parents about potential reference cycle.
e7a8fe3
@barneygale
makepath() --> __newpath__()
b3bb8bd
@bedevere-bot bedevere-bot mentioned this pull request Apr 28, 2023
Support for sharing state between pathlib subclasses #100479
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Apr 28, 2023
@barneygale barneygale mentioned this pull request Apr 28, 2023
GH-100479: Add optional blueprint argument to pathlib.PurePath #100481
Closed
merwok
merwok reviewed Apr 28, 2023
View reviewed changes
Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

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

barneygale added 2 commits April 29, 2023 17:51
@barneygale
Look up __newpath__ on path type.
cdedc92
@barneygale
__newpath__ --> _newpath_
8341566
@barneygale barneygale changed the title GH-100479: Add pathlib.PurePath.__newpath__() GH-100479: Add pathlib.PurePath._newpath_() Apr 29, 2023
AlexWaygood
AlexWaygood approved these changes Apr 30, 2023
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

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.

My personal preference is still for the version with the initializer argument, but it's a weakly held preference, and I think I'm in the minority. This looks good, and you have my approval whichever way you decide to go :)

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Apr 30, 2023
@merwok

merwok commented Apr 30, 2023

Copy link
Copy Markdown
Member

I also find the initializer argument nicer than a method.

(But I may be in the minority for style, I have no trouble doing from datetime import datetime, timezone for example…)

barneygale reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@barneygale
_newpath_ --> with_segments
610b0c4
@barneygale barneygale changed the title GH-100479: Add pathlib.PurePath._newpath_() GH-100479: Add pathlib.PurePath.with_segments() May 1, 2023
@barneygale
with_segments --> with_path
7f28ed3
@barneygale
Merge branch 'main' into pythongh-100479-add-makepath-redux
51fe663
@barneygale barneygale changed the title GH-100479: Add pathlib.PurePath.with_segments() GH-100479: Add pathlib.PurePath.with_path() May 2, 2023
@barneygale
Revert "with_segments --> with_path"
961e2bf
This reverts commit 7f28ed3.
@barneygale barneygale changed the title GH-100479: Add pathlib.PurePath.with_path() GH-100479: Add pathlib.PurePath.with_segments() May 4, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label May 4, 2023
@barneygale
barneygale marked this pull request as ready for review May 4, 2023 18:09
@barneygale barneygale added topic-pathlib awaiting merge labels May 4, 2023
@barneygale
Merge branch 'main' into pythongh-100479-add-makepath-redux
39297cf
@barneygale
barneygale enabled auto-merge (squash) May 5, 2023 18:26
@barneygale
barneygale disabled auto-merge May 5, 2023 18:37
Gobot1234 added a commit to Gobot1234/steam.py that referenced this pull request May 5, 2023
@Gobot1234
Implement changes for python/cpython#103975
4733287
@barneygale
*args --> *pathsegments
4e28944
@barneygale
barneygale enabled auto-merge (squash) May 5, 2023 18:42
@barneygale
barneygale merged commit d00d942 into python:main May 5, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label May 5, 2023
@ericsnowcurrently

ericsnowcurrently commented May 5, 2023

Copy link
Copy Markdown
Member

FYI, it looks like the wasm32-wasi buildbot doesn't like this change: https://buildbot.python.org/all/#/builders/1046/builds/1922.

barneygale reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

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

carljm added a commit to carljm/cpython that referenced this pull request May 5, 2023
@carljm
Merge branch 'main' into inlinecomp2
baacf5f
* main:
  pythongh-99113: Add PyInterpreterConfig.own_gil (pythongh-104204)
  pythongh-104146: Remove unused var 'parser_body_declarations' from clinic.py (python#104214)
  pythongh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (pythongh-104205)
  pythongh-104108: Add the Py_mod_multiple_interpreters Module Def Slot (pythongh-104148)
  pythongh-99113: Share the GIL via PyInterpreterState.ceval.gil (pythongh-104203)
  pythonGH-100479: Add `pathlib.PurePath.with_segments()` (pythonGH-103975)
  pythongh-69152: Add _proxy_response_headers attribute to HTTPConnection (python#26152)
  pythongh-103533: Use PEP 669 APIs for cprofile (pythonGH-103534)
  pythonGH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque for users of PEP 523. (pythonGH-96849)
jbower-fb pushed a commit to jbower-fb/cpython that referenced this pull request May 8, 2023
@barneygale @AlexWaygood @jbower-fb
pythonGH-100479: Add pathlib.PurePath.with_segments() (pythonGH-103975
0b62e96
)

Add `pathlib.PurePath.with_segments()`, which creates a path object from arguments. This method is called whenever a derivative path is created, such as from `pathlib.PurePath.parent`. Subclasses may override this method to share information between path objects.

Co-authored-by: Alex Waygood <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merwok merwok merwok left review comments
@eryksun eryksun eryksun left review comments
@AlexWaygood AlexWaygood AlexWaygood approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

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.

6 participants

@barneygale @merwok @ericsnowcurrently @eryksun @AlexWaygood @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.