mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
#6707 fix a crash with dir() on an uninitialized module
This commit is contained in:
parent
75e1f9985a
commit
4c6e8088f5
3 changed files with 8 additions and 3 deletions
|
@ -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))
|
||||
|
|
|
@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 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
|
||||
|
|
|
@ -1810,9 +1810,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue