##// END OF EJS Templates
py3: conditionalize _winreg import...
Pulkit Goyal -
r29760:3df9f780 default
parent child Browse files
Show More
@@ -1,6 +1,5 b''
1 1 from __future__ import absolute_import
2 2
3 import _winreg
4 3 import os
5 4
6 5 from . import (
@@ -8,6 +7,12 b' from . import ('
8 7 util,
9 8 )
10 9
10 try:
11 import _winreg as winreg
12 winreg.CloseKey
13 except ImportError:
14 import winreg
15
11 16 def systemrcpath():
12 17 '''return default os-specific hgrc search path'''
13 18 rcpath = []
@@ -23,7 +28,7 b' def systemrcpath():'
23 28 rcpath.append(os.path.join(progrcd, f))
24 29 # else look for a system rcpath in the registry
25 30 value = util.lookupreg('SOFTWARE\\Mercurial', None,
26 _winreg.HKEY_LOCAL_MACHINE)
31 winreg.HKEY_LOCAL_MACHINE)
27 32 if not isinstance(value, str) or not value:
28 33 return rcpath
29 34 value = util.localpath(value)
@@ -7,7 +7,6 b''
7 7
8 8 from __future__ import absolute_import
9 9
10 import _winreg
11 10 import errno
12 11 import msvcrt
13 12 import os
@@ -22,6 +21,12 b' from . import ('
22 21 win32,
23 22 )
24 23
24 try:
25 import _winreg as winreg
26 winreg.CloseKey
27 except ImportError:
28 import winreg
29
25 30 executablepath = win32.executablepath
26 31 getuser = win32.getuser
27 32 hidewindow = win32.hidewindow
@@ -432,12 +437,12 b' def lookupreg(key, valname=None, scope=N'
432 437 LOCAL_MACHINE).
433 438 '''
434 439 if scope is None:
435 scope = (_winreg.HKEY_CURRENT_USER, _winreg.HKEY_LOCAL_MACHINE)
440 scope = (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE)
436 441 elif not isinstance(scope, (list, tuple)):
437 442 scope = (scope,)
438 443 for s in scope:
439 444 try:
440 val = _winreg.QueryValueEx(_winreg.OpenKey(s, key), valname)[0]
445 val = winreg.QueryValueEx(winreg.OpenKey(s, key), valname)[0]
441 446 # never let a Unicode string escape into the wild
442 447 return encoding.tolocal(val.encode('UTF-8'))
443 448 except EnvironmentError:
@@ -146,7 +146,7 b''
146 146 mercurial/revlog.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
147 147 mercurial/revset.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
148 148 mercurial/scmutil.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
149 mercurial/scmwindows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
149 mercurial/scmwindows.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
150 150 mercurial/similar.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
151 151 mercurial/simplemerge.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
152 152 mercurial/sshpeer.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
@@ -167,7 +167,7 b''
167 167 mercurial/url.py: error importing: <TypeError> getattr(): attribute name must be string (error at util.py:*) (glob)
168 168 mercurial/verify.py: error importing: <TypeError> attribute name must be string, not 'bytes' (error at mdiff.py:*) (glob)
169 169 mercurial/win32.py: error importing module: <ImportError> No module named 'msvcrt' (line *) (glob)
170 mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
170 mercurial/windows.py: error importing module: <ImportError> No module named 'msvcrt' (line *) (glob)
171 171 mercurial/wireproto.py: error importing module: <TypeError> a bytes-like object is required, not 'str' (line *) (glob)
172 172
173 173 #endif
General Comments 0
You need to be logged in to leave comments. Login now