]> granicus.if.org Git - python/commitdiff
Merged revisions 74457 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Sat, 15 Aug 2009 13:18:47 +0000 (13:18 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 15 Aug 2009 13:18:47 +0000 (13:18 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r74457 | benjamin.peterson | 2009-08-15 08:16:38 -0500 (Sat, 15 Aug 2009) | 1 line

  #6707 fix a crash with dir() on an uninitialized module
........

Lib/test/test_module.py
Misc/NEWS
Objects/object.c

index e0c7ec3b9fc0028a80e5bbb578bf28febc5cf56f..ac997734322fbec63522aa4f502f5ec05fefe30e 100644 (file)
@@ -11,6 +11,7 @@ class ModuleTests(unittest.TestCase):
         # and __doc__ is None
         foo = ModuleType.__new__(ModuleType)
         self.failUnless(foo.__dict__ is None)
+        self.assertRaises(SystemError, dir, foo)
         try:
             s = foo.__name__
             self.fail("__name__ = %s" % repr(s))
index 8b0f7ab8b0c1f735433e88531656c01d5290353b..4b8bb707098ce83505463bc5ca36b64935ea1d48 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.6.3
 Core and Builtins
 -----------------
 
+- Issue #6707: dir() on an uninitialized module caused a crash.
+
 - Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
 
 - Issue #6573: set.union() stopped processing inputs if an instance of self
index bb3693b64320d638d947687bced2ace7006d8ae9..0e97e8cd57214220e6957380623375cd4b31e25f 100644 (file)
@@ -1806,9 +1806,11 @@ _specialized_dir_module(PyObject *obj)
                if (PyDict_Check(dict))
                        result = PyDict_Keys(dict);
                else {
-                       PyErr_Format(PyExc_TypeError,
-                                    "%.200s.__dict__ is not a dictionary",
-                                    PyModule_GetName(obj));
+                       char *name = PyModule_GetName(obj);
+                       if (name)
+                               PyErr_Format(PyExc_TypeError,
+                                            "%.200s.__dict__ is not a dictionary",
+                                            name);
                }
        }