@@ -17,7 +17,7 @@ def _get_module_path(file_path, sys_paths):
1717 will get turned into great_app.simple_expansions.simple_interface given that the syspath contains
1818 /tmp/bin/python/site-packages
1919
20- We are making sure we're removing the current path.
20+ We are making sure we're removing the current path for this special usecase, by checking if it contains "/./" .
2121 For example, '/Users/mirelap/Documents/workspace/JSON/aws-codeguru-profiler-python-demo-application/sample-demo-django-app/./polls/views.py'
2222 will get turned into `polls.views' given that the file path contains the current path.
2323 This should not happen usually, but we've found a case where the "/." is added when calling traceback.walk_stack(..)
@@ -40,6 +40,7 @@ def _get_module_path(file_path, sys_paths):
4040
4141 # remove suffix
4242 module_path = str (Path (module_path ).with_suffix ("" ))
43+
4344 # remove drive (applicable for WINDOWS customers)
4445 module_path = os .path .splitdrive (module_path )[1 ]
4546
@@ -52,12 +53,17 @@ def _get_module_path(file_path, sys_paths):
5253
5354
5455def _remove_prefix_path (module_path , sys_paths ):
55- current_path = str (Path ().absolute ())
56- if current_path in module_path :
57- return module_path .replace (current_path , "" ).replace ("/./" , "/" )
56+ if "/./" in module_path and platform .system () != "Windows" :
57+ module_path = module_path .replace ("/./" , "/" )
58+ current_path = str (Path ().absolute ())
59+ if current_path != "/" : # this may be Fargate
60+ return module_path .replace (current_path , "" )
61+ return module_path
62+
5863 for root in sys_paths :
5964 if root in module_path :
6065 return module_path .replace (root , "" )
66+
6167 return module_path
6268
6369class ProfileEncoder :
0 commit comments