]> granicus.if.org Git - python/commitdiff
#6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
authorTarek Ziadé <ziade.tarek@gmail.com>
Mon, 21 Sep 2009 13:41:08 +0000 (13:41 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Mon, 21 Sep 2009 13:41:08 +0000 (13:41 +0000)
Lib/distutils/dist.py
Lib/distutils/log.py
Lib/distutils/tests/test_dist.py
Misc/NEWS

index afed545d92c7901faadfd376518b67f7e9035a6a..f49afcce135342d03442d71c23c05c98a3724b96 100644 (file)
@@ -359,7 +359,7 @@ Common commands: (see '--help-commands' for more)
         parser = ConfigParser()
         for filename in filenames:
             if DEBUG:
-                self.announce("  reading", filename)
+                self.announce("  reading %s" % filename)
             parser.read(filename)
             for section in parser.sections():
                 options = parser.options(section)
index 6f949d517936c6c6ea4fd1ac6cc587be3d6f9fdd..758857081c80e13ec772aea668323961478a752b 100644 (file)
@@ -17,6 +17,9 @@ class Log:
         self.threshold = threshold
 
     def _log(self, level, msg, args):
+        if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
+            raise ValueError('%s wrong log level' % str(level))
+
         if level >= self.threshold:
             if args:
                 msg = msg % args
index 553f30c748b3de738a836eaae38429e9ef541a40..3d4b25f0fcea1136a43075e827c2ca6a67168023 100644 (file)
@@ -200,6 +200,13 @@ class DistributionTestCase(support.TempdirManager,
         self.assertEquals(cmds, ['distutils.command', 'one', 'two'])
 
 
+    def test_announce(self):
+        # make sure the level is known
+        dist = Distribution()
+        args = ('ok',)
+        kwargs = {'level': 'ok2'}
+        self.assertRaises(ValueError, dist.announce, args, kwargs)
+
 class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
                        unittest.TestCase):
 
index 8261b6c21030749eeda26614501450b277ccd1d7..1cc8f741b3451cc4731ba66c1092fd444c15cb9e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -379,6 +379,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
+
 - Issue #6851: Fix urllib.urlopen crash on secondairy threads on OSX 10.6
 
 - Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...)