[Python-checkins] distutils2: Fix import error on Python 2.x

jason.coombs python-checkins at python.org
Wed Mar 14 00:06:06 CET 2012


http://hg.python.org/distutils2/rev/09e86884295c
changeset:   1302:09e86884295c
user:        Jason R. Coombs <jaraco at jaraco.com>
date:        Tue Mar 13 16:05:51 2012 -0700
summary:
  Fix import error on Python 2.x

files:
  distutils2/compiler/msvc9compiler.py |  6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/distutils2/compiler/msvc9compiler.py b/distutils2/compiler/msvc9compiler.py
--- a/distutils2/compiler/msvc9compiler.py
+++ b/distutils2/compiler/msvc9compiler.py
@@ -20,7 +20,11 @@
 from distutils2 import logger
 from distutils2.util import get_platform
 
-import winreg
+try:
+    import winreg
+except ImportError:
+    # Python 2 compatibility
+    import _winreg as winreg
 
 RegOpenKeyEx = winreg.OpenKeyEx
 RegEnumKey = winreg.EnumKey

-- 
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list