Is xyz (for instance, os.path.isabs) behavior change intentional (ANSWERED)

Someone asked essentially the following on the python tracker:
On Windows, import os; os.path.isabs('/user/file') returns True in 3.12 and False in 3.13. Is this change intentional? I am answering here both generically and specifically for the benefit of others.

Answer 1: Check the docs. isabs doc says
" Changed in version 3.13: On Windows, returns False if the given path starts with exactly one (back)slash."
Yes.

Answer 2: If the doc has no answer, check the code with git blame, such as on github.
A. Go to GitHub - python/cpython: The Python programming language.
B. Click <> Code in the upper left. Find the relevant file, which here is Lib/ntpath. Arrive at
cpython/Lib/ntpath.py at main · python/cpython · GitHub
C. In either order, click Blame in the Code window and file the relevant code, which here is def isabs. Arrive at Blaming cpython/Lib/ntpath.py at main · python/cpython · GitHub.
D. Consider when the change had to be made. 3.13 was release about 2024 Oct 1, so the change had to be after about June 1, 2023. There are 2 possible recent changes, including the return line. This line is unusual in having more that one issue linked. Click the first. Arrive at
Add os.path.isrelative() and improve ntpath.isabs() · Issue #44626 · python/cpython · GitHub
This issue is unusual in spanning 18 years and over 50 comments. One could click Load more (32 remaining items) for the comments just before the change, but instead
E. Click the linked PR in the opening box to arrive at
GH-44626, GH-105476: Fix `ntpath.isabs()` handling of part-absolute paths by barneygale · Pull Request #113829 · python/cpython · GitHub, opened Jan 8 and merged Jan 13, 2024. The message in the top box says “On Windows, os.path.isabs() now returns False when given a path that starts with exactly one (back)slash.” Again, Yes. Very intentional.

The change wouldn’t be unreasonable given that there’s no drive letter specified, so it’s relative to the root of an unspecified drive.

Before browsing the code, I’d look on What’s New In Python 3.13. And then next would be the Changelog it links to.

And a simpler way to find Lib/ntpath.py would be to look for a source code link at the top of the os.path documentation.

1 Like