summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-08-15 13:25:28 +0000
committerBenjamin Peterson <benjamin@python.org>2009-08-15 13:25:28 +0000
commit044446b67cfe108c215ac58ebc71778ca4e73aa5 (patch)
tree51dea842aef5ef01e1b59a509ceda44a56012f24
parent43226f8bd0582e33810043d4f350f3d8d4a6e7c8 (diff)
downloadcpython-git-044446b67cfe108c215ac58ebc71778ca4e73aa5.tar.gz
Merged revisions 74459 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r74459 | benjamin.peterson | 2009-08-15 08:23:05 -0500 (Sat, 15 Aug 2009) | 9 lines Merged revisions 74457 via svnmerge from 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 ........ ................
-rw-r--r--Lib/test/test_module.py1
-rw-r--r--Misc/NEWS2
-rw-r--r--Objects/object.c8
3 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
index 225e954fc4..0e56290655 100644
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -11,6 +11,7 @@ class ModuleTests(unittest.TestCase):
# and __doc__ is None
foo = ModuleType.__new__(ModuleType)
self.assertTrue(foo.__dict__ is None)
+ self.assertRaises(SystemError, dir, foo)
try:
s = foo.__name__
self.fail("__name__ = %s" % repr(s))
diff --git a/Misc/NEWS b/Misc/NEWS
index 8e56852dba..d6000b0fed 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 3.1.1?
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
diff --git a/Objects/object.c b/Objects/object.c
index a29c31a43d..b2c7c140ae 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1265,9 +1265,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));
+ const char *name = PyModule_GetName(obj);
+ if (name)
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.__dict__ is not a dictionary",
+ name);
}
}