| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Signed-off-by: Filipe Laíns <lains@riseup.net>
| 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.
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 a problem hiding this comment.
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.
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
|
Well, this is kind of messy. It seems that several tests rely on being able to feed real_executable a fake path. Since this is then used to search for the standard library directories, we cannot easily modify the behavior without causing breakage for some embedding users. I'm gonna see if I can find a way to do this without breaking the module path calculation. |
Sorry, something went wrong.
|
Indeed. sys.executable cannot be assumed to exist or simply be set to /proc/self/exe -> 's symlink target for such reasons. 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 sys.executable = None or something like sys.executable = "/<non-existant-path and explanation>" made up by the embedder such that any code which tries to use the string winds up with an explanation of what's wrong in the error message. Especially when the embedder has fully embedded the standard library in a hermetic executable manner. |
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
$ bash -c "exec -a echo $(pwd)/python -c 'import sys; print(sys.executable)'" /home/anubis/git/cpython/python