Kaydet (Commit) f492c364 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

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
........
üst 1cfc9c0e
...@@ -11,6 +11,7 @@ class ModuleTests(unittest.TestCase): ...@@ -11,6 +11,7 @@ class ModuleTests(unittest.TestCase):
# and __doc__ is None # and __doc__ is None
foo = ModuleType.__new__(ModuleType) foo = ModuleType.__new__(ModuleType)
self.failUnless(foo.__dict__ is None) self.failUnless(foo.__dict__ is None)
self.assertRaises(SystemError, dir, foo)
try: try:
s = foo.__name__ s = foo.__name__
self.fail("__name__ = %s" % repr(s)) self.fail("__name__ = %s" % repr(s))
......
...@@ -12,6 +12,8 @@ What's New in Python 2.6.3 ...@@ -12,6 +12,8 @@ What's New in Python 2.6.3
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #6707: dir() on an uninitialized module caused a crash.
- Issue #6540: Fixed crash for bytearray.translate() with invalid parameters. - Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
- Issue #6573: set.union() stopped processing inputs if an instance of self - Issue #6573: set.union() stopped processing inputs if an instance of self
......
...@@ -1806,9 +1806,11 @@ _specialized_dir_module(PyObject *obj) ...@@ -1806,9 +1806,11 @@ _specialized_dir_module(PyObject *obj)
if (PyDict_Check(dict)) if (PyDict_Check(dict))
result = PyDict_Keys(dict); result = PyDict_Keys(dict);
else { else {
PyErr_Format(PyExc_TypeError, char *name = PyModule_GetName(obj);
"%.200s.__dict__ is not a dictionary", if (name)
PyModule_GetName(obj)); PyErr_Format(PyExc_TypeError,
"%.200s.__dict__ is not a dictionary",
name);
} }
} }
......
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