Skip to content

Conversation

@bobzinin
Copy link

@bobzinin bobzinin commented Dec 1, 2025

Improve documentation of how Python sets sys.path[0] when the script is accessed via different link types:

  • On Unix-like systems, symbolic links are resolved to target directory
  • Hard links and Windows file links use the link's own directory

Fixes #58752


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

Comment on lines 162 to 164
If the script name refers to a link, the behavior depends on the link type and operating system.
On Unix-like systems, symbolic links are resolved to the target file's directory when added to :data:`sys.path`.
Hard links use the link's own directory. On Windows, both hard links and symbolic links use the link's own directory.
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap lines to 79 characters.

Improve documentation of how Python sets sys.path[0] when the script
is accessed via different link types:
- On Unix-like systems, symbolic links are resolved to target directory
- Hard links and Windows file links use the link's own directory

Fixes python#58752
@bobzinin bobzinin force-pushed the document-symlink-behavior branch from 90033d8 to b3035ff Compare December 1, 2025 20:30
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

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Document behaviour of python when launched on symlink to a script

2 participants