Skip to content

Commit

Permalink
#4 Rootpath: Fixed Infinite loop for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nagesh-chowdaiah authored and grimen committed Mar 31, 2021
1 parent f5446bf commit ed6df33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rootpath/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def find_root_path(current_path, pattern = None):
if found_system_root:
return None

system_root = sys.executable
while os.path.split(system_root)[1]:
system_root = os.path.split(system_root)[0]

if current_path == system_root:
return None

current_path = path.abspath(path.join(current_path, '..'))

return find_root_path(current_path, pattern)
4 changes: 4 additions & 0 deletions rootpath/tests/test_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def test_rootpath_detect_entry_nested_pattern(self):

self.assertEqual(root_path, None)

def test_system_root(self):
root_path = rootpath.detect(r"\Users\Public\Downloads")
self.assertEqual(root_path, None)


# =========================================
# MAIN
Expand Down

0 comments on commit ed6df33

Please sign in to comment.