Skip to content

gh-140971: Doc: Clarify pathlib.Path("") behavior - #140993

Closed
LiuQhahah wants to merge 1 commit into
python:mainfrom
LiuQhahah:#140971-unexpected-behavior-of-pathlib-with-empty-string
Closed

gh-140971: Doc: Clarify pathlib.Path("") behavior#140993
LiuQhahah wants to merge 1 commit into
python:mainfrom
LiuQhahah:#140971-unexpected-behavior-of-pathlib-with-empty-string

Conversation

@LiuQhahah

@LiuQhahah LiuQhahah commented Nov 4, 2025

Copy link
Copy Markdown

Fixes #140971
This PR clarifies the behavior of pathlib.Path("") in the documentation.

The current behavior, where pathlib.Path("").exists() returns True, is intentional but
can be confusing because it differs from os.path.exists(""), which returns False.

This change adds a note to the PurePath constructor documentation to explain that an empty string path segment refers to the current directory. This makes the behavior explicit to users and helps prevent further confusion.


📚 Documentation preview 📚: https://cpython-previews--140993.org.readthedocs.build/

@python-cla-bot

python-cla-bot Bot commented Nov 4, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Comment thread Doc/library/pathlib.rst
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 1, 2026
@StanFromIreland

Copy link
Copy Markdown
Member

I'm sorry but I am closing as Terry's changes haven't been made in several months.

@terryjreedy

Copy link
Copy Markdown
Member

If you approve of my suggestion, I will make the change and merge.

@StanFromIreland

Copy link
Copy Markdown
Member

It looks good to me, please ping when you open a PR and I can approve.

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

Labels

awaiting review docs Documentation in the Doc dir skip news stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

unexpected behavior of pathlib with empty string

4 participants