Coder Social home page Coder Social logo

Comments (10)

barneygale avatar barneygale commented on June 29, 2024 1

We don't need to document every detail of what realpath() does. Tests would be welcome, though

from cpython.

barneygale avatar barneygale commented on June 29, 2024

os.path.realpath() resolves the path using the current OS's rules, which might be more specific than POSIX. Both my Linux and macOS machines resolve //foo to /foo. Are there any supported Python platforms where // isn't resolved to /?

from cpython.

nineteendo avatar nineteendo commented on June 29, 2024

I'm currently on my Windows laptop, so I can't check.
In any case, the old implementation can never return //foo because path is set to os.sep.
Is there a "needs investigation" label?

from cpython.

barneygale avatar barneygale commented on June 29, 2024

There doesn't seem to be anything like a "needs investigation" label.

Happy to leave this issue open for a bit while you further research a repro case, but if we can't find one, then I think this issue should be closed as "can't repro".

from cpython.

nineteendo avatar nineteendo commented on June 29, 2024

Also, the current behaviour is undocumented:

Join two paths, normalizing and eliminating any symbolic links encountered in the second path.

Normalizing doesn't touch the double slash & // is not a symlink.

from cpython.

barneygale avatar barneygale commented on June 29, 2024

You're quoting a comment above the internal _joinrealpath() function.

Both the posixpath.realpath() docstring, and the online docs, describe it as returning a canonical path. The online docs add:

This function emulates the operating system’s procedure for making a path canonical

from cpython.

nineteendo avatar nineteendo commented on June 29, 2024

OK, but that comment doesn't document this feature, which it probably should, in case this works correctly.

from cpython.

bluss avatar bluss commented on June 29, 2024

Why do you want to fix this, and could you describe in more detail how the changes relate to the specification you are pointing to? I don't see what in the specification requires this.

from cpython.

nineteendo avatar nineteendo commented on June 29, 2024

Yep, the old behaviour seems to be correct (cd doesn't resolve symlinks), in that case the feature should just be documented and tested.

  • macOS:
    Screenshot 2024-03-29 at 09 04 52
  • Pydroid 3:
    image

from cpython.

nineteendo avatar nineteendo commented on June 29, 2024

I've added just one sentence in this pull request: #117350.

Join two paths, normalizing and eliminating any symbolic links encountered in the second path. Two leading slashes are replaced by a single slash.

Where should I add the test though? It doesn't really fit in with the rest of the changes.

from cpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.