[Python-checkins] r74459 - in python/branches/py3k: Lib/test/test_module.py Misc/NEWS Objects/object.c

benjamin.peterson python-checkins at python.org
Sat Aug 15 15:23:05 CEST 2009


Author: benjamin.peterson
Date: Sat Aug 15 15:23:05 2009
New Revision: 74459
Log:
Merged revisions 74457 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk
........
 r74457 | benjamin.peterson | 2009年08月15日 08:16:38 -0500 (2009年8月15日) | 1 line
 
 #6707 fix a crash with dir() on an uninitialized module
........
Modified:
 python/branches/py3k/ (props changed)
 python/branches/py3k/Lib/test/test_module.py
 python/branches/py3k/Misc/NEWS
 python/branches/py3k/Objects/object.c
Modified: python/branches/py3k/Lib/test/test_module.py
==============================================================================
--- python/branches/py3k/Lib/test/test_module.py	(original)
+++ python/branches/py3k/Lib/test/test_module.py	Sat Aug 15 15:23:05 2009
@@ -11,6 +11,7 @@
 # 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))
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Aug 15 15:23:05 2009
@@ -12,6 +12,8 @@
 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
Modified: python/branches/py3k/Objects/object.c
==============================================================================
--- python/branches/py3k/Objects/object.c	(original)
+++ python/branches/py3k/Objects/object.c	Sat Aug 15 15:23:05 2009
@@ -1265,9 +1265,11 @@
 		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);
 		}
 	}
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /