diff options
author | Georg Brandl <georg@python.org> | 2008-05-25 07:25:25 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-05-25 07:25:25 (GMT) |
commit | 392c6fc02d90f211dadc72448a07d9281260cb70 (patch) | |
tree | 8cc4d563ee077ef83612a67a02ce36f5c2397d37 /Lib | |
parent | 995ee9dab0a89b139e08a55fc64a60aaddc0d5c0 (diff) | |
download | cpython-392c6fc02d90f211dadc72448a07d9281260cb70.zip cpython-392c6fc02d90f211dadc72448a07d9281260cb70.tar.gz cpython-392c6fc02d90f211dadc72448a07d9281260cb70.tar.bz2 |
ConfigParser renaming reversal part 3: move module into place and adapt imports.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ConfigParser.py (renamed from Lib/lib-old/ConfigParser.py) | 0 | ||||
-rw-r--r-- | Lib/distutils/command/upload.py | 6 | ||||
-rw-r--r-- | Lib/distutils/config.py | 6 | ||||
-rw-r--r-- | Lib/distutils/dist.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/configHandler.py | 2 | ||||
-rw-r--r-- | Lib/logging/config.py | 4 | ||||
-rw-r--r-- | Lib/test/test___all__.py | 2 | ||||
-rw-r--r-- | Lib/test/test_cfgparser.py | 36 | ||||
-rw-r--r-- | Lib/test/test_py3kwarn.py | 41 |
9 files changed, 26 insertions, 77 deletions
diff --git a/Lib/lib-old/ConfigParser.py b/Lib/ConfigParser.py index 65c6ae2..65c6ae2 100644 --- a/Lib/lib-old/ConfigParser.py +++ b/Lib/ConfigParser.py diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py index 92c4bf2..8805d41 100644 --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@ -14,11 +14,7 @@ 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 +from ConfigParser import ConfigParser class upload(PyPIRCCommand): diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py index e07f8ac..e3a4c57 100644 --- a/Lib/distutils/config.py +++ b/Lib/distutils/config.py @@ -5,11 +5,7 @@ that uses .pypirc in the distutils.command package. """ import os import sys -try: - from configparser import ConfigParser -except ImportError: - # For backward-compatibility with Python versions < 2.6. - from ConfigParser import ConfigParser +from ConfigParser import ConfigParser from distutils.cmd import Command diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 6299919..0a21380 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -358,11 +358,7 @@ Common commands: (see '--help-commands' for more) def parse_config_files (self, filenames=None): - try: - from configparser import ConfigParser - except ImportError: - # For backward-compatibility with Python versions < 2.6. - from ConfigParser import ConfigParser + from ConfigParser import ConfigParser if filenames is None: filenames = self.find_config_files() diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index bdce85d..3fc2a60 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -21,7 +21,7 @@ import os import sys import string import macosxSupport -from configparser import ConfigParser, NoOptionError, NoSectionError +from ConfigParser import ConfigParser, NoOptionError, NoSectionError class InvalidConfigType(Exception): pass class InvalidConfigSet(Exception): pass diff --git a/Lib/logging/config.py b/Lib/logging/config.py index dc13723..c95842c 100644 --- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -65,9 +65,9 @@ def fileConfig(fname, defaults=None): rather than a filename, in which case the file-like object will be read using readfp. """ - import configparser + import ConfigParser - cp = configparser.ConfigParser(defaults) + cp = ConfigParser.ConfigParser(defaults) if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): cp.readfp(fname) else: diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 57933d2..1076c61 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -37,7 +37,7 @@ class AllTest(unittest.TestCase): self.check_all("BaseHTTPServer") self.check_all("Bastion") self.check_all("CGIHTTPServer") - self.check_all("configparser") + self.check_all("ConfigParser") self.check_all("Cookie") self.check_all("MimeWriter") self.check_all("Queue") diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 4dfa795..a8b5d7c 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -1,4 +1,4 @@ -import configparser +import ConfigParser import StringIO import unittest import UserDict @@ -94,7 +94,7 @@ class TestCaseBase(unittest.TestCase): "remove_option() failed to report non-existance of option" " that was removed") - self.assertRaises(configparser.NoSectionError, + self.assertRaises(ConfigParser.NoSectionError, cf.remove_option, 'No Such Section', 'foo') eq(cf.get('Long Line', 'foo'), @@ -147,17 +147,17 @@ class TestCaseBase(unittest.TestCase): def test_parse_errors(self): self.newconfig() - self.parse_error(configparser.ParsingError, + self.parse_error(ConfigParser.ParsingError, "[Foo]\n extra-spaces: splat\n") - self.parse_error(configparser.ParsingError, + self.parse_error(ConfigParser.ParsingError, "[Foo]\n extra-spaces= splat\n") - self.parse_error(configparser.ParsingError, + self.parse_error(ConfigParser.ParsingError, "[Foo]\noption-without-value\n") - self.parse_error(configparser.ParsingError, + self.parse_error(ConfigParser.ParsingError, "[Foo]\n:value-without-option-name\n") - self.parse_error(configparser.ParsingError, + self.parse_error(ConfigParser.ParsingError, "[Foo]\n=value-without-option-name\n") - self.parse_error(configparser.MissingSectionHeaderError, + self.parse_error(ConfigParser.MissingSectionHeaderError, "No Section!\n") def parse_error(self, exc, src): @@ -170,13 +170,13 @@ class TestCaseBase(unittest.TestCase): "new ConfigParser should have no defined sections") self.failIf(cf.has_section("Foo"), "new ConfigParser should have no acknowledged sections") - self.assertRaises(configparser.NoSectionError, + self.assertRaises(ConfigParser.NoSectionError, cf.options, "Foo") - self.assertRaises(configparser.NoSectionError, + self.assertRaises(ConfigParser.NoSectionError, cf.set, "foo", "bar", "value") - self.get_error(configparser.NoSectionError, "foo", "bar") + self.get_error(ConfigParser.NoSectionError, "foo", "bar") cf.add_section("foo") - self.get_error(configparser.NoOptionError, "foo", "bar") + self.get_error(ConfigParser.NoOptionError, "foo", "bar") def get_error(self, exc, section, option): try: @@ -215,7 +215,7 @@ class TestCaseBase(unittest.TestCase): def test_weird_errors(self): cf = self.newconfig() cf.add_section("Foo") - self.assertRaises(configparser.DuplicateSectionError, + self.assertRaises(ConfigParser.DuplicateSectionError, cf.add_section, "Foo") def test_write(self): @@ -324,7 +324,7 @@ class TestCaseBase(unittest.TestCase): class ConfigParserTestCase(TestCaseBase): - config_class = configparser.ConfigParser + config_class = ConfigParser.ConfigParser def test_interpolation(self): cf = self.get_interpolation_config() @@ -335,11 +335,11 @@ class ConfigParserTestCase(TestCaseBase): "something with lots of interpolation (9 steps)") eq(cf.get("Foo", "bar10"), "something with lots of interpolation (10 steps)") - self.get_error(configparser.InterpolationDepthError, "Foo", "bar11") + self.get_error(ConfigParser.InterpolationDepthError, "Foo", "bar11") def test_interpolation_missing_value(self): cf = self.get_interpolation_config() - e = self.get_error(configparser.InterpolationError, + e = self.get_error(ConfigParser.InterpolationError, "Interpolation Error", "name") self.assertEqual(e.reference, "reference") self.assertEqual(e.section, "Interpolation Error") @@ -375,7 +375,7 @@ class ConfigParserTestCase(TestCaseBase): class RawConfigParserTestCase(TestCaseBase): - config_class = configparser.RawConfigParser + config_class = ConfigParser.RawConfigParser def test_interpolation(self): cf = self.get_interpolation_config() @@ -410,7 +410,7 @@ class RawConfigParserTestCase(TestCaseBase): class SafeConfigParserTestCase(ConfigParserTestCase): - config_class = configparser.SafeConfigParser + config_class = ConfigParser.SafeConfigParser def test_safe_interpolation(self): # See http://www.python.org/sf/511737 diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index a456154..180342b 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -213,48 +213,9 @@ class TestStdlibRemovals(unittest.TestCase): self.assertEquals(str(w.message), msg) -class TestStdlibRenames(unittest.TestCase): - - renames = {'ConfigParser': 'configparser'} - - def check_rename(self, module_name, new_module_name): - """Make sure that: - - A DeprecationWarning is raised when importing using the - old 2.x module name. - - The module can be imported using the new 3.x name. - - The warning message specify both names. - """ - with CleanImport(module_name): - with catch_warning(record=False) as w: - warnings.filterwarnings("error", ".+ renamed to", - DeprecationWarning) - try: - __import__(module_name, level=0) - except DeprecationWarning as exc: - self.assert_(module_name in exc.args[0]) - self.assert_(new_module_name in exc.args[0]) - else: - self.fail("DeprecationWarning not raised for %s" % - module_name) - with CleanImport(new_module_name): - try: - __import__(new_module_name, level=0) - except ImportError: - self.fail("cannot import %s with its 3.x name, %s" % - module_name, new_module_name) - except DeprecationWarning: - self.fail("unexpected DeprecationWarning raised for %s" % - module_name) - - def test_module_renames(self): - for module_name, new_module_name in self.renames.items(): - self.check_rename(module_name, new_module_name) - - def test_main(): run_unittest(TestPy3KWarnings, - TestStdlibRemovals, - TestStdlibRenames) + TestStdlibRemovals) if __name__ == '__main__': test_main() |