-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Description
Bug report
Bug description:
To reproduce (Bash):
❯ ./python -m pdb <(echo 'print("Hello world!")')
Error: /dev/fd/63 does not existThis isn't exactly right. /dev/fd/63 was a symlink to an existing anonymous pipe, but it was checked after being processed with os.path.realpath (which made the path unusable for open or stat -- GH-99390):
Lines 184 to 190 in 706fdda
| class _ScriptTarget(_ExecutableTarget): | |
| def __init__(self, target): | |
| self._target = os.path.realpath(target) | |
| if not os.path.exists(self._target): | |
| print(f'Error: {target} does not exist') | |
| sys.exit(1) |
Technically, this is a 3.11 regression caused by https://github.com/python/cpython/pull/26992/files#r663030110.
The new behavior was preserved in the refactor of executable targets in Pdb (GH-112570). Before these two patches, os.path.realpath was only used in Pdb to figure out the directory to be set as sys.path[0] since GH-23338. Prior to that, os.path.realpath wasn't used in Pdb at all.
To fix this edge case, I think we could simply bring back the old behavior of passing the raw path to system functions and continue to use the real path elsewhere.
A dead-simple workaround is to just use regular files.
CC @jaraco @iritkatriel @gaogaotiantian
CC @ZeroIntensity (mentorship): stdlib, 3.13 & 3.14 (unless it's a feature at this point), 3.15. Not sure if I would give this OS-specific labels.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux