Skip to content

Commit 7050770

Browse files
committed
Pick target depending on preconditions
1 parent 572c780 commit 7050770

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Lib/pdb.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,17 @@ class _ExecutableTarget:
183183

184184
class _ScriptTarget(_ExecutableTarget):
185185
def __init__(self, target):
186-
self._target = os.path.realpath(target)
187-
188-
if not os.path.exists(self._target):
186+
if not os.path.exists(target):
189187
print(f'Error: {target} does not exist')
190188
sys.exit(1)
191-
if os.path.isdir(self._target):
189+
if os.path.isdir(target):
192190
print(f'Error: {target} is a directory')
193191
sys.exit(1)
194192

193+
# Be careful with realpath to support pseudofilesystems (GH-142315).
194+
realpath = os.path.realpath(target)
195+
self._target = realpath if os.path.exists(realpath) else target
196+
195197
# If safe_path(-P) is not set, sys.path[0] is the directory
196198
# of pdb, and we should replace it with the directory of the script
197199
if not sys.flags.safe_path:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pdb can run scripts from pseudofiles. Patch by Bartosz Sławecki.

0 commit comments

Comments
 (0)