@@ -17,7 +17,7 @@ def _get_module_path(file_path, sys_paths):
17
17
will get turned into great_app.simple_expansions.simple_interface given that the syspath contains
18
18
/tmp/bin/python/site-packages
19
19
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 "/./" .
21
21
For example, '/Users/mirelap/Documents/workspace/JSON/aws-codeguru-profiler-python-demo-application/sample-demo-django-app/./polls/views.py'
22
22
will get turned into `polls.views' given that the file path contains the current path.
23
23
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):
40
40
41
41
# remove suffix
42
42
module_path = str (Path (module_path ).with_suffix ("" ))
43
+
43
44
# remove drive (applicable for WINDOWS customers)
44
45
module_path = os .path .splitdrive (module_path )[1 ]
45
46
@@ -52,12 +53,17 @@ def _get_module_path(file_path, sys_paths):
52
53
53
54
54
55
def _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
+
58
63
for root in sys_paths :
59
64
if root in module_path :
60
65
return module_path .replace (root , "" )
66
+
61
67
return module_path
62
68
63
69
class ProfileEncoder :
0 commit comments