Commit 142d8815 authored by Tarek Ziadé's avatar Tarek Ziadé

#6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.

parent 06106987
......@@ -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)
......
......@@ -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
......
......@@ -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):
......
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