]> granicus.if.org Git - python/commitdiff
fixed #4646 : distutils was choking on empty options arg in the setup function.
authorTarek Ziadé <ziade.tarek@gmail.com>
Mon, 29 Dec 2008 22:23:53 +0000 (22:23 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Mon, 29 Dec 2008 22:23:53 +0000 (22:23 +0000)
Lib/distutils/dist.py
Lib/distutils/tests/test_dist.py
Misc/NEWS

index 9ad94fbeb8353321b6c87e115b204bfec10ff4d5..c15ca9770da75f93988601a41066d779e01c5e75 100644 (file)
@@ -235,7 +235,7 @@ Common commands: (see '--help-commands' for more)
             # command options will override any supplied redundantly
             # through the general options dictionary.
             options = attrs.get('options')
-            if options:
+            if options is not None:
                 del attrs['options']
                 for (command, cmd_options) in options.items():
                     opt_dict = self.get_option_dict(command)
index 6f5fe9c757560cd1c3a2cdbce603770c315095f1..bf59c418442c2193717971dbe1f9128e1fbb8e23 100644 (file)
@@ -8,6 +8,7 @@ import os
 import StringIO
 import sys
 import unittest
+import warnings
 
 from test.test_support import TESTFN
 
@@ -131,6 +132,29 @@ class DistributionTestCase(unittest.TestCase):
             if os.path.exists(my_file):
                 os.remove(my_file)
 
+    def test_empty_options(self):
+        # an empty options dictionary should not stay in the
+        # list of attributes
+        klass = distutils.dist.Distribution
+
+        # catching warnings
+        warns = []
+        def _warn(msg):
+            warns.append(msg)
+
+        old_warn = warnings.warn
+        warnings.warn = _warn
+        try:
+            dist = klass(attrs={'author': 'xxx',
+                                'name': 'xxx',
+                                'version': 'xxx',
+                                'url': 'xxxx',
+                                'options': {}})
+        finally:
+            warnings.warn = old_warn
+
+        self.assertEquals(len(warns), 0)
+
 class MetadataTestCase(unittest.TestCase):
 
     def test_simple_metadata(self):
index 1fd8d3331627afff991fa074f48c9a1ccf7e61ad..539a41a08fce584807d1776a0c36ce44a2787782 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -97,6 +97,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #4646: distutils was choking on empty options arg in the setup 
+  function. Original patch by Thomas Heller.
+
 - Issue #3767: Convert Tk object to string in tkColorChooser.
 
 - Issue #3248: Allow placing ScrolledText in a PanedWindow.