Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-124241: try reading/proc/self/exe to determinesys.executable#145486

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
FFY00 wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromFFY00:gh-124241
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
On POSIX, we now try to read the symlink target from ``/proc/self/exe`` to
determine:data:`sys.executable`.
7 changes: 7 additions & 0 deletionsModules/getpath.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -265,6 +265,13 @@ def search_up(prefix, *landmarks, test=isfile):
ifnotexecutable:
executable=real_executable

ifnotexecutableandos_name=='posix':
# On Linux, try resolving the executable path via procfs
try:
executable=realpath('/proc/self/exe')
Copy link
Member

Choose a reason for hiding this comment

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

realpath() returns/proc/self/exe unmodified if it cannot resolve the symlink. I would prefer usingreadlink() here. But it requires more work, sinceModules/getpath.c doesn't implement it here. I can help implementingreadlink() ingetpath.c if you want.

except (OSError,MemoryError):
pass
Comment on lines +268 to +273
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Humm, perhaps we should do this after tryingprogram_name, and only update the value if the executable path derived fromprogram_name doesn't resolve to the same path as/proc/self/exe.

Ifprogam_name is set and resolves to the same path as/proc/self/exe, honoring its value should be nicer.


ifnotexecutableandSEPinprogram_name:
# Resolve partial path program_name against current directory
executable=abspath(program_name)
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp