From eb8cef26648d7d443a5570a2e653d9d07c284c42 Mon Sep 17 00:00:00 2001 From: Alexandre Vassalotti Date: Fri, 16 May 2008 02:06:59 +0000 Subject: [PATCH] Fixed import of configparser in the distutils module. If configparser is unavailable, try to import configparser using its old name. This is required for backward-compatibility with older Python versions. --- Lib/distutils/command/upload.py | 7 ++++++- Lib/distutils/config.py | 6 +++++- Lib/distutils/dist.py | 7 +++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py index daf681128d7..92c4bf204e1 100644 --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@ -10,11 +10,16 @@ from hashlib import md5 import os import socket import platform -import ConfigParser import httplib import base64 import urlparse import cStringIO as StringIO +try: + from configparser import ConfigParser +except ImportError: + # For backward-compatibility with Python versions < 2.6. + from ConfigParser import ConfigParser + class upload(PyPIRCCommand): diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py index f1117beed15..35a21ec2114 100644 --- a/Lib/distutils/config.py +++ b/Lib/distutils/config.py @@ -5,7 +5,11 @@ that uses .pypirc in the distutils.command package. """ import os import sys -from ConfigParser import ConfigParser +try: + from configparser import ConfigParser +except ImportError: + # For backward-compatibility with Python versions < 2.6. + from ConfigParser import ConfigParser from distutils.cmd import Command diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 0b13c1e6c19..6299919fdfd 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -358,8 +358,11 @@ Common commands: (see '--help-commands' for more) def parse_config_files (self, filenames=None): - - from ConfigParser import ConfigParser + try: + from configparser import ConfigParser + except ImportError: + # For backward-compatibility with Python versions < 2.6. + from ConfigParser import ConfigParser if filenames is None: filenames = self.find_config_files()