gh-101000: Add os.path.splitroot() by barneygale · Pull Request #101002 · python/cpython · GitHub

github.com

Tin mới

barneygale:gh-101000-splitroot

GitHub CopilotWrite better code with AI

GitHub Copilot appDirect agents from issue to merge

ActionsAutomate any workflow

CodespacesInstant dev environments

IssuesPlan and track work

Code ReviewManage code changes

Code QualityEnforce quality at merge

GitHub Advanced SecurityFind and fix vulnerabilities

Code securitySecure your code as you build

Secret protectionStop leaks before they start

View all use cases

Financial services

View all industries

Software Development

GitHub SponsorsFund open source developers

Copilot for BusinessEnterprise-grade AI features

Premium SupportEnterprise-grade 24/7 support

Pull requests 2.6k

Security and quality 0

Add os.path.splitroot() function #101000

: Add os.path.splitroot()

Use splitroot() from pathlib

Use splitroot() from posixpath

Use splitroot() from ntpath

View reviewed changes

Learn more about hiding disruptive comments

The reason will be displayed to describe this comment to others. Learn more.

Correct and expand examples in splitroot() docstring

View reviewed changes

Update Lib/ntpath.py

Use splitroot() from pathlib.PurePath.with_name()

Reduce ntpath.normpath() diff noise

Simplify ntpath.commonpath() now that 'isabs' is unused.

View reviewed changes

Reduce posixpath.normpath() diff noise

Improve documentation

Add whatsnew entry.

Simplify ntpath.splitroot() slightly

View reviewed changes

Apply suggestions from code review

View reviewed changes

Update Doc/library/os.path.rst

Note that drive may be empty on Windows

View reviewed changes

cpython/Lib/test/test_ntpath.py

Update Doc/library/os.path.rst

Add tests for bytes (POSIX only) and path-like objects (both platforms)

View reviewed changes

Add tests for mixed path separators (Windows only)

Remove errant newline.