]> granicus.if.org Git - python/commitdiff
Merged revisions 74994,74997 via svnmerge from
authorTarek Ziadé <ziade.tarek@gmail.com>
Mon, 21 Sep 2009 13:55:19 +0000 (13:55 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Mon, 21 Sep 2009 13:55:19 +0000 (13:55 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r74994 | tarek.ziade | 2009-09-21 15:41:08 +0200 (Mon, 21 Sep 2009) | 1 line

  #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
........
  r74997 | tarek.ziade | 2009-09-21 15:49:57 +0200 (Mon, 21 Sep 2009) | 1 line

  forgot to commit a file in previous commit (r74994, issue #6954)
........

Lib/distutils/dist.py
Lib/distutils/log.py
Lib/distutils/tests/support.py
Lib/distutils/tests/test_dist.py
Misc/NEWS

index ac5a0ca012052f9669d0c2f058acb71fd46db3ea..1c1ea477db4bc671bb126664024a48b5a8f6d64d 100644 (file)
@@ -354,7 +354,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 1255413989ec87d4132d0a65f5a90fb1e082cb90..ea122111caa9f844f205a46d025a31ed96f65890 100644 (file)
@@ -4,6 +4,7 @@ import shutil
 import tempfile
 
 from distutils import log
+from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
 from distutils.core import Distribution
 from test.support import EnvironmentVarGuard
 
@@ -25,6 +26,8 @@ class LoggingSilencer(object):
         super().tearDown()
 
     def _log(self, level, msg, args):
+        if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
+            raise ValueError('%s wrong log level' % str(level))
         self.logs.append((level, msg, args))
 
     def get_logs(self, *levels):
index 91297f0e158a47c53386d54e8322241148e580ae..799b0c060377aa5b4a04ba23f10170b19d37160c 100644 (file)
@@ -171,6 +171,13 @@ class DistributionTestCase(support.LoggingSilencer,
         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 528b3fdc3b030737bfad34be71114bd7367cdc47..6948fc6fc262fb5c7d9d2eb4f6b29e0804deb3ff 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1064,6 +1064,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
+
 - Issue #6163: Fixed HP-UX runtime library dir options in
   distutils.unixcompiler. Initial patch by Sridhar Ratnakumar and
   Michael Haubenwallner.