##// END OF EJS Templates
util: disinfect lookup_reg strings (issue1126)...
Matt Mackall -
r6880:892806b3 default
parent child Browse files
Show More
@@ -201,21 +201,17 b' def lookup_reg(key, valname=None, scope='
201 except ImportError:
201 except ImportError:
202 return None
202 return None
203
203
204 def query_val(scope, key, valname):
205 try:
206 keyhandle = OpenKey(scope, key)
207 return QueryValueEx(keyhandle, valname)[0]
208 except EnvironmentError:
209 return None
210
211 if scope is None:
204 if scope is None:
212 scope = (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE)
205 scope = (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE)
213 elif not isinstance(scope, (list, tuple)):
206 elif not isinstance(scope, (list, tuple)):
214 scope = (scope,)
207 scope = (scope,)
215 for s in scope:
208 for s in scope:
216 val = query_val(s, key, valname)
209 try:
217 if val is not None:
210 val = QueryValueEx(OpenKey(scope, key), valname)[0]
218 return val
211 # never let a Unicode string escape into the wild
212 return util.tolocal(val.encode('UTF-8'))
213 except EnvironmentError:
214 pass
219
215
220 def system_rcpath_win32():
216 def system_rcpath_win32():
221 '''return default os-specific hgrc search path'''
217 '''return default os-specific hgrc search path'''
General Comments 0
You need to be logged in to leave comments. Login now