[Python-bugs-list] [ python-Bugs-486826 ] bogus error message on bad parameters

noreply@sourceforge.net noreply@sourceforge.net
Fri, 30 Nov 2001 01:38:08 -0800


Bugs item #486826, was opened at 2001-11-28 20:56
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=486826&group_id=5470

Category: Python Interpreter Core
Group: None
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: bogus error message on bad parameters

Initial Comment:
I was writing a CGI and ran across the following error message: 
TypeError: 'in <string>' requires character as left operand, which 
drove me batty as I keep thinking it was the left operand when in 
reality it was the right operand....  I've simplified the problem to 

Python 2.1.1 (#1, Oct 30 2001, 09:41:48) 
[GCC 2.95.2 19991024 (release)] on darwin1
Type "copyright", "credits" or "license" for more information.
>>> mystrings = "AE,Developer"
>>> "AE" in mystrings
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'in <string>' requires character as left operand
>>> 

maybe it's just me but I keep thinking that "AE" is the left operand 
and it has a character.... 

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2001-11-29 19:59

Message:
Logged In: NO 

Ok, I played with the code some more.... and learned a 
thing or two... I now realize that the "in" command can 
be used on non lists such as  "a in 'abcd'" whereas I 
was trying to do "'AE' in ['AE','Developer']" as part of the 
CGI.

Python v1.5.2 didn't help that much as the error 
reported was "TypeError: string member test needs 
char left operand".

Had I had my thinking cap on, I would have seen the 
difference in the Python 2.1.1 error message 'in <
string>' which would have indicated that the right hand 
side was a string vs the list I was expecting...

Now knowing this, I think it's safe that we can close this 
bug. Thanks for teaching me something new today!

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-11-29 10:23

Message:
Logged In: YES 
user_id=21627

I can't see the bug. Sure "AE" *has* a character (actually
two of them), but it *is* not a character - a character is a
string of length 1. You need such a thing on the left-hand
side of 'in <string>'.

How would you formulate the error message?

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=486826&group_id=5470