@@ -106,18 +106,25 @@ def enum_paths(self):
106106 basedir = path [0 ]
107107 sys32 = len (path ) > 1 and path [1 ].lower () == "system32"
108108 if basedir == "SystemRoot" :
109- if not sys32 or "PE32+" not in self .config .file_type :
110- yield os .path .join (os .getenv ("SystemRoot" ), * path [1 :])
111- yield os .path .join (os .getenv ("SystemRoot" ), "sysnative" , * path [2 :])
109+ system_root = os .getenv ("SystemRoot" )
110+ if system_root :
111+ file_type = getattr (self .config , "file_type" , "" ) or ""
112+ if not sys32 or "PE32+" not in file_type :
113+ yield os .path .join (system_root , * path [1 :])
114+ if sys32 :
115+ yield os .path .join (system_root , "sysnative" , * path [2 :])
116+ # Fallback for 64-bit Python where sysnative is not available
117+ if "PE32+" in file_type :
118+ yield os .path .join (system_root , * path [1 :])
112119 elif basedir == "ProgramFiles" :
113120 if os .getenv ("ProgramFiles(x86)" ):
114121 yield os .path .join (os .getenv ("ProgramFiles(x86)" ), * path [1 :])
115- yield os .path .join (os .getenv ("ProgramFiles" ).replace (" (x86)" , "" ), * path [1 :])
122+ if os .getenv ("ProgramFiles" ):
123+ yield os .path .join (os .getenv ("ProgramFiles" ).replace (" (x86)" , "" ), * path [1 :])
116124 elif basedir == "HomeDrive" :
117- # os.path.join() does not work well when giving just C:
118- # instead of C:\\, so we manually add the backslash.
119- homedrive = "{}\\ " .format (os .getenv ("HomeDrive" ))
120- yield os .path .join (homedrive , * path [1 :])
125+ homedrive = os .getenv ("HomeDrive" )
126+ if homedrive :
127+ yield os .path .join (f"{ homedrive } \\ " , * path [1 :])
121128 elif os .getenv (basedir ):
122129 yield os .path .join (os .getenv (basedir ), * path [1 :])
123130 else :
0 commit comments