File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -183,13 +183,9 @@ class _ExecutableTarget:
183183
184184class _ScriptTarget (_ExecutableTarget ):
185185 def __init__ (self , target ):
186+ self ._target = target
186187 self ._check (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 )
188+ self ._replace_sys_path (target )
193189
194190 @staticmethod
195191 def _check (target ):
@@ -203,6 +199,13 @@ def _check(target):
203199 print (f'Error: { target } is a directory' )
204200 sys .exit (1 )
205201
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+
206209 def __repr__ (self ):
207210 return self ._target
208211
You can’t perform that action at this time.
0 commit comments