diff mercurial/scmwindows.py @ 29760:3df9f780c90e

py3: conditionalize _winreg import _winreg module is renamed to winreg in python 3. Added the conditionalize statements in the respective file because adding this in pycompat will result in pycompat throwing error as this is a windows registry module and we have buildbots and most of the contributors on linux.
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 10 Aug 2016 04:35:44 +0530
parents 029f02757c20
children 4b1af1c867fa
line wrap: on
line diff
--- a/mercurial/scmwindows.py	Mon Aug 08 23:51:11 2016 +0530
+++ b/mercurial/scmwindows.py	Wed Aug 10 04:35:44 2016 +0530
@@ -1,6 +1,5 @@
 from __future__ import absolute_import
 
-import _winreg
 import os
 
 from . import (
@@ -8,6 +7,12 @@
     util,
 )
 
+try:
+    import _winreg as winreg
+    winreg.CloseKey
+except ImportError:
+    import winreg
+
 def systemrcpath():
     '''return default os-specific hgrc search path'''
     rcpath = []
@@ -23,7 +28,7 @@
                 rcpath.append(os.path.join(progrcd, f))
     # else look for a system rcpath in the registry
     value = util.lookupreg('SOFTWARE\\Mercurial', None,
-                           _winreg.HKEY_LOCAL_MACHINE)
+                           winreg.HKEY_LOCAL_MACHINE)
     if not isinstance(value, str) or not value:
         return rcpath
     value = util.localpath(value)