Commit 6d4d4281 authored by Tarek Ziadé's avatar Tarek Ziadé

Merged revisions 74994,74997 via svnmerge from

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)
........
parent 5b731778
...@@ -354,7 +354,7 @@ Common commands: (see '--help-commands' for more) ...@@ -354,7 +354,7 @@ Common commands: (see '--help-commands' for more)
parser = ConfigParser() parser = ConfigParser()
for filename in filenames: for filename in filenames:
if DEBUG: if DEBUG:
self.announce(" reading", filename) self.announce(" reading %s" % filename)
parser.read(filename) parser.read(filename)
for section in parser.sections(): for section in parser.sections():
options = parser.options(section) options = parser.options(section)
......
...@@ -17,6 +17,9 @@ class Log: ...@@ -17,6 +17,9 @@ class Log:
self.threshold = threshold self.threshold = threshold
def _log(self, level, msg, args): 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 level >= self.threshold:
if args: if args:
msg = msg % args msg = msg % args
......
...@@ -4,6 +4,7 @@ import shutil ...@@ -4,6 +4,7 @@ import shutil
import tempfile import tempfile
from distutils import log from distutils import log
from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
from distutils.core import Distribution from distutils.core import Distribution
from test.support import EnvironmentVarGuard from test.support import EnvironmentVarGuard
...@@ -25,6 +26,8 @@ class LoggingSilencer(object): ...@@ -25,6 +26,8 @@ class LoggingSilencer(object):
super().tearDown() super().tearDown()
def _log(self, level, msg, args): 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)) self.logs.append((level, msg, args))
def get_logs(self, *levels): def get_logs(self, *levels):
......
...@@ -171,6 +171,13 @@ class DistributionTestCase(support.LoggingSilencer, ...@@ -171,6 +171,13 @@ class DistributionTestCase(support.LoggingSilencer,
self.assertEquals(cmds, ['distutils.command', 'one', 'two']) 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, class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
unittest.TestCase): unittest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment