File tree Expand file tree Collapse file tree
ni_measurementlink_service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,16 +44,35 @@ def _get_caller_path() -> Optional[Path]:
4444 for frame , _ in traceback .walk_stack (inspect .currentframe ()):
4545 if frame .f_code .co_filename :
4646 module_path = Path (frame .f_code .co_filename )
47- if module_path . exists ( ) and not _is_relative_to (module_path , nims_path ):
47+ if _exists ( module_path ) and not _is_relative_to (module_path , nims_path ):
4848 return module_path
4949
5050 return None
5151
5252
53- def _is_relative_to (path : PurePath , other : PurePath ) -> bool :
54- if sys .version_info >= (3 , 9 ):
53+ # Path.exists() throws OSError when the path has invalid file characters.
54+ # https://github.com/python/cpython/issues/79487
55+ if sys .version_info >= (3 , 10 ):
56+
57+ def _exists (path : Path ) -> bool :
58+ return path .exists ()
59+
60+ else :
61+
62+ def _exists (path : Path ) -> bool :
63+ import os
64+
65+ return os .path .exists (path )
66+
67+
68+ if sys .version_info >= (3 , 9 ):
69+
70+ def _is_relative_to (path : PurePath , other : PurePath ) -> bool :
5571 return path .is_relative_to (other )
56- else :
72+
73+ else :
74+
75+ def _is_relative_to (path : PurePath , other : PurePath ) -> bool :
5776 try :
5877 _ = path .relative_to (other )
5978 return True
You can’t perform that action at this time.
0 commit comments