#5624: _winreg is winreg in Python 3.

This commit is contained in:
Georg Brandl 2009-04-01 04:28:33 +00:00
parent 99412e559b
commit 4ed72acd68
4 changed files with 16 additions and 14 deletions

View file

@ -48,8 +48,8 @@ class msvc9compilerTestCase(unittest.TestCase):
v = Reg.get_value(path, "lfitalic") v = Reg.get_value(path, "lfitalic")
self.assert_(v in (0, 1)) self.assert_(v in (0, 1))
import _winreg import winreg
HKCU = _winreg.HKEY_CURRENT_USER HKCU = winreg.HKEY_CURRENT_USER
keys = Reg.read_keys(HKCU, 'xxxx') keys = Reg.read_keys(HKCU, 'xxxx')
self.assertEquals(keys, None) self.assertEquals(keys, None)

View file

@ -2160,18 +2160,18 @@ elif os.name == 'nt':
""" """
proxies = {} proxies = {}
try: try:
import _winreg import winreg
except ImportError: except ImportError:
# Std module, so should be around - but you never know! # Std module, so should be around - but you never know!
return proxies return proxies
try: try:
internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r'Software\Microsoft\Windows\CurrentVersion\Internet Settings') r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
proxyEnable = _winreg.QueryValueEx(internetSettings, proxyEnable = winreg.QueryValueEx(internetSettings,
'ProxyEnable')[0] 'ProxyEnable')[0]
if proxyEnable: if proxyEnable:
# Returned as Unicode but problems if not converted to ASCII # Returned as Unicode but problems if not converted to ASCII
proxyServer = str(_winreg.QueryValueEx(internetSettings, proxyServer = str(winreg.QueryValueEx(internetSettings,
'ProxyServer')[0]) 'ProxyServer')[0])
if '=' in proxyServer: if '=' in proxyServer:
# Per-protocol settings # Per-protocol settings
@ -2208,17 +2208,17 @@ elif os.name == 'nt':
def proxy_bypass_registry(host): def proxy_bypass_registry(host):
try: try:
import _winreg import winreg
import re import re
except ImportError: except ImportError:
# Std modules, so should be around - but you never know! # Std modules, so should be around - but you never know!
return 0 return 0
try: try:
internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r'Software\Microsoft\Windows\CurrentVersion\Internet Settings') r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
proxyEnable = _winreg.QueryValueEx(internetSettings, proxyEnable = winreg.QueryValueEx(internetSettings,
'ProxyEnable')[0] 'ProxyEnable')[0]
proxyOverride = str(_winreg.QueryValueEx(internetSettings, proxyOverride = str(winreg.QueryValueEx(internetSettings,
'ProxyOverride')[0]) 'ProxyOverride')[0])
# ^^^^ Returned as Unicode but problems if not converted to ASCII # ^^^^ Returned as Unicode but problems if not converted to ASCII
except WindowsError: except WindowsError:

View file

@ -53,6 +53,8 @@ Core and Builtins
Library Library
------- -------
- Issue #5624: Fix the _winreg module name still used in several modules.
- Issue #5628: Fix io.TextIOWrapper.read() with a unreadable buffer. - Issue #5628: Fix io.TextIOWrapper.read() with a unreadable buffer.
- Issue #5619: Multiprocessing children disobey the debug flag and causes - Issue #5619: Multiprocessing children disobey the debug flag and causes

View file

@ -5,7 +5,7 @@ import win32com.client.gencache
import win32com.client import win32com.client
import pythoncom, pywintypes import pythoncom, pywintypes
from win32com.client import constants from win32com.client import constants
import re, string, os, sets, glob, subprocess, sys, _winreg, struct import re, string, os, sets, glob, subprocess, sys, winreg, struct
try: try:
basestring basestring
@ -387,9 +387,9 @@ class CAB:
(r"Software\Microsoft\Win32SDK\Directories", "Install Dir"), (r"Software\Microsoft\Win32SDK\Directories", "Install Dir"),
]: ]:
try: try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, k) key = winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, k)
dir = _winreg.QueryValueEx(key, v)[0] dir = winreg.QueryValueEx(key, v)[0]
_winreg.CloseKey(key) winreg.CloseKey(key)
except (WindowsError, IndexError): except (WindowsError, IndexError):
continue continue
cabarc = os.path.join(dir, r"Bin", "cabarc.exe") cabarc = os.path.join(dir, r"Bin", "cabarc.exe")