File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,9 +183,13 @@ class _ExecutableTarget:
183183
184184class _ScriptTarget (_ExecutableTarget ):
185185 def __init__ (self , target ):
186- self ._target = target
187186 self ._check (target )
188- self ._replace_sys_path (target )
187+ self ._target = os .path .realpath (target )
188+
189+ # If PYTHONSAFEPATH (-P) is not set, sys.path[0] is the directory
190+ # of pdb, and we should replace it with the directory of the script
191+ if not sys .flags .safe_path :
192+ sys .path [0 ] = os .path .dirname (self ._target )
189193
190194 @staticmethod
191195 def _check (target ):
@@ -199,13 +203,6 @@ def _check(target):
199203 print (f'Error: { target } is a directory' )
200204 sys .exit (1 )
201205
202- @staticmethod
203- def _replace_sys_path (target ):
204- # If PYTHONSAFEPATH (-P) is not set, sys.path[0] is the directory
205- # of pdb, so replace it with the directory of the script
206- if not sys .flags .safe_path :
207- sys .path [0 ] = os .path .dirname (os .path .realpath (target ))
208-
209206 def __repr__ (self ):
210207 return self ._target
211208
You can’t perform that action at this time.
0 commit comments