Obscure Exception message

Michael Hudson mwh21 at cam.ac.uk
Fri Jun 9 08:28:50 EDT 2000


Thomas Wouters <thomas at xs4all.net> writes:

> On Thu, Jun 08, 2000 at 05:28:58PM -0400, Andrew M. Kuchling wrote:
> 
> > "Daley, MarkX" <markx.daley at intel.com> writes:
> > > TypeError: string member test needs char left operand
> > > I have no idea what this is telling me, although the 'char' comment makes me
> > > wish I had a flamethrower!
> 
> > Good point.  Hmm... how about:
> > TypeError: in <string> requires character as left operand
> 
> Put quotes around 'in <string>':
> 
> TypeError: 'in <string>' requires character as left operand
> 

The Rapid-Fire-Python-Error-Message-Improver (me) says:

Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.66
diff -u -r2.66 stringobject.c
--- stringobject.c	2000/06/01 03:12:13	2.66
+++ stringobject.c	2000/06/09 12:24:54
@@ -393,7 +393,7 @@
 		return PyUnicode_Contains(a, el);
 	if (!PyString_Check(el) || PyString_Size(el) != 1) {
 		PyErr_SetString(PyExc_TypeError,
-				"string member test needs char left operand");
+		    "'in <string>' requires character as left operand");
 		return -1;
 	}
 	c = PyString_AsString(el)[0];
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.21
diff -u -r2.21 unicodeobject.c
--- unicodeobject.c	2000/05/09 19:54:43	2.21
+++ unicodeobject.c	2000/06/09 12:25:01
@@ -2991,7 +2991,7 @@
     /* Check v in u */
     if (PyUnicode_GET_SIZE(v) != 1) {
 	PyErr_SetString(PyExc_TypeError,
-			"string member test needs char left operand");
+	    "'in <string>' requires character as left operand");
 	goto onError;
     }
     ch = *PyUnicode_AS_UNICODE(v);

and:

I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.

Cheers,
M.

-- 
93. When someone says "I want a programming language in which I
    need only say what I wish done," give him a lollipop.
  -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html



More information about the Python-list mailing list