Commits

Yuya Nishihara committed 9e6f4f8

gpg: remove unnecessary handling of ImportError of _winreg

On Windows, _winreg module must exist, and we use it in several places.

Comments (0)

Files changed (1)

tortoisehg/util/gpg.py

 def findgpg(ui):
     path = []
     if os.name == 'nt':
-        try:
-            import _winreg
-            for key in (r"Software\GNU\GnuPG", r"Software\Wow6432Node\GNU\GnuPG"):
-                try:
-                    hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key)
-                    pfx = _winreg.QueryValueEx(hkey, 'Install Directory')[0]
-                    for dirPath, dirNames, fileNames in os.walk(pfx):
-                        for f in fileNames:
-                            if f == 'gpg.exe':
-                                path.append(os.path.join(dirPath, f))
-                except WindowsError:
-                    pass
-                except EnvironmentError:
-                    pass
-        except ImportError:
-            pass
+        import _winreg
+        for key in (r"Software\GNU\GnuPG", r"Software\Wow6432Node\GNU\GnuPG"):
+            try:
+                hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key)
+                pfx = _winreg.QueryValueEx(hkey, 'Install Directory')[0]
+                for dirPath, dirNames, fileNames in os.walk(pfx):
+                    for f in fileNames:
+                        if f == 'gpg.exe':
+                            path.append(os.path.join(dirPath, f))
+            except WindowsError:
+                pass
+            except EnvironmentError:
+                pass
 
     return path