[Python-checkins] r58108 - in python/trunk: Lib/test/test_generators.py Misc/NEWS Objects/genobject.c

brett.cannon python-checkins at python.org
Tue Sep 11 23:02:28 CEST 2007


Author: brett.cannon
Date: Tue Sep 11 23:02:28 2007
New Revision: 58108

Modified:
   python/trunk/Lib/test/test_generators.py
   python/trunk/Misc/NEWS
   python/trunk/Objects/genobject.c
Log:
Generators had their throw() method allowing string exceptions.  That's a
no-no.

Fixes issue #1147.  Need to fix 2.5 to raise a proper warning if a string
exception is passed in.


Modified: python/trunk/Lib/test/test_generators.py
==============================================================================
--- python/trunk/Lib/test/test_generators.py	(original)
+++ python/trunk/Lib/test/test_generators.py	Tue Sep 11 23:02:28 2007
@@ -1622,7 +1622,7 @@
 >>> f().throw("abc")     # throw on just-opened generator
 Traceback (most recent call last):
   ...
-abc
+TypeError: exceptions must be classes, or instances, not str
 
 Now let's try closing a generator:
 

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Sep 11 23:02:28 2007
@@ -12,6 +12,9 @@
 Core and builtins
 -----------------
 
+- Issue #1147: Exceptions were directly allowing string exceptions in their
+  throw() method even though string exceptions no longer allowed.
+
 - Issue #1096: Prevent a segfault from getting the repr of a very deeply nested
   list by using the recursion counter.
 

Modified: python/trunk/Objects/genobject.c
==============================================================================
--- python/trunk/Objects/genobject.c	(original)
+++ python/trunk/Objects/genobject.c	Tue Sep 11 23:02:28 2007
@@ -252,10 +252,7 @@
 			Py_INCREF(typ);
 		}
 	}
-
-	/* Allow raising builtin string exceptions */
-
-	else if (!PyString_CheckExact(typ)) {
+	else {
 		/* Not something you can raise.  throw() fails. */
 		PyErr_Format(PyExc_TypeError,
 			     "exceptions must be classes, or instances, not %s",


More information about the Python-checkins mailing list