Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pathlib docs: Method Path.absolute is missing from docs <v3.11 (also distinction from Path.resolve and rel. topics) #121682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
e-d-n-a opened this issue Jul 13, 2024 · 2 comments
Labels
docs Documentation in the Doc dir topic-pathlib

Comments

@e-d-n-a
Copy link

e-d-n-a commented Jul 13, 2024

Documentation

Method Path.absolute is missing from docs <v3.11 (I checked all of them: 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10).
It only appears in docs for v3.11+[3], although it is part of the class Path since pathlib was added in v3.4[1,2].

It would be useful to have, as one needs to see the distinction between Path.absolute and Path.resolve (which is included in the docs since v3.4) in regards to normalization or resolving symlinks for example (see docstrings or docs for v3.11[3]).

Docstrings taken from pathlib.py of v3.9.17:
(I appreciate the explicit mentioning of the treatment of '.' and '..' with Path.absolute in this version!)

    def absolute(self):
        """Return an absolute version of this path.  This function works
        even if the path doesn't point to anything.

        No normalization is done, i.e. all '.' and '..' will be kept along.
        Use resolve() to get the canonical path to a file.
        """

    def resolve(self, strict=False):
        """
        Make the path absolute, resolving all symlinks on the way and also
        normalizing it (for example turning slashes into backslashes under
        Windows).
        """

(these functions also appear next to each other in the code[4])

It would be nice, if the topics of "path normalization" and "symlink resolving" would be described more clearly in the context of those functions. The handling of '..' is mentioned in the context of Path.resolve and also PurePaths (in constructor and PurePath.parent).
Yet, the trap with Path.absolute is only mentioned by the documenation for Path.resolve stating:
“..” components are also eliminated (this is the only method to do so):

Refs:

  1. Blame for Method Path.absolute()
  2. Commit including pathlib.py for v3.4
  3. Path.absolute() in Docs for v3.11
  4. Path.absolute and Path.resolve in code of v3.11.9 (docstring for Path.absolute is simplified here though!)
@e-d-n-a e-d-n-a added the docs Documentation in the Doc dir label Jul 13, 2024
@e-d-n-a e-d-n-a changed the title pathlib docs: Method Path.absolute is missing from docs <v3.11 (also destinction from Path.resolve and rel. topics) pathlib docs: Method Path.absolute is missing from docs <v3.11 (also distinction from Path.resolve and rel. topics) Jul 13, 2024
@Eclips4
Copy link
Member

Eclips4 commented Jul 13, 2024

Hello! Thanks for the report.
Unfortunately, we cannot fix that due to CPython policy: versions older than 3.12 accept only security fixes. This one is not about security :(

@Eclips4 Eclips4 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2024
@e-d-n-a
Copy link
Author

e-d-n-a commented Jul 13, 2024

I found the issue (#73874) now, that actually discussed all this thoroughly from 2017 till 2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-pathlib
Projects
None yet
Development

No branches or pull requests

2 participants