Source

pygame / msys.py

Diff from to

File msys.py

 import subprocess
 import re
 import glob
-import _winreg
+try:
+    import _winreg
+except ImportError:
+    import winreg as _winreg
+
+# For Python 2.x/3.x compatibility
+def geterror():
+    return sys.exc_info()[1]
 
 FSTAB_REGEX = (r'^[ \t]*(?P<path>'
                r'([a-zA-Z]:){0,1}([\\/][^\s*^?:%\\/]+)+)'
         dir_path = os.path.abspath(dir_path)
         try:
             return find_msys_version_subdir(dir_path)
-        except MsysException, e:
-            msys_print(e)
+        except MsysException:
+            msys_print(geterror())
             
 def find_msys_registry():
     """Return the MSYS 1.0 directory path stored in the Windows registry
     
     subkey = (
         'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MSYS-1.0_is1')
-    key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey)
     try:
+        key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey)
         try:
             return _winreg.QueryValueEx(key, 'Inno Setup: App Path')[0].encode()
-        except WindowsError:
-            raise LookupError("MSYS not found in the registry")
-    finally:
-        key.Close()
+        finally:
+            key.Close()
+    except WindowsError:
+        raise LookupError("MSYS not found in the registry")
 
 def as_shell(msys_root):
     """Append MSYS shell program to MSYS root directory path"""