GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — GH-124241: try reading `/proc/self/exe` to determine `sys.executable` by FFY00 · Pull Request #145486 · python/cpython Conversation
|
| if not executable and os_name == 'posix': | ||
| # On Linux, try resolving the executable path via procfs | ||
| try: | ||
| executable = realpath('/proc/self/exe') |
There was a problem 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 using readlink() here. But it requires more work, since Modules/getpath.c doesn't implement it here. I can help implementing readlink() in getpath.c if you want.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Right, using readlink would also be my preference, I just went for this implementation for simplicity. We could move this to progname_to_dict (computes real_executable), but we should still try to honor program_name if it points to the same path.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Signed-off-by: Filipe Laíns <[email protected]>
Signed-off-by: Filipe Laíns <[email protected]>
Signed-off-by: Filipe Laíns <[email protected]>
Signed-off-by: Filipe Laíns <[email protected]>
|
Well, this is kind of messy. It seems that several tests rely on being able to feed I'm gonna see if I can find a way to do this without breaking the module path calculation. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Indeed. There may be no meaningful executable, and the actual executed binary if it even exists on a filesystem that /proc/self/exe can point to, does not have to be a Python interpreter or behave like one. It is common to see two behaviors in embedding scenarios, either |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.