[Python-bugs-list] [ python-Bugs-459334 ] urllib2 __getitem__ problem

noreply@sourceforge.net noreply@sourceforge.net
Tue, 18 Sep 2001 13:19:03 -0700


Bugs item #459334, was opened at 2001-09-06 15:18
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=459334&group_id=5470

Category: Extension Modules
Group: Python 2.1.1
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: urllib2 __getitem__ problem

Initial Comment:
urllib2's file-like object has a bug in its 
__getitem__ method. Try getting item 5 or item [], 
both valid queries as far as dict-like objects go, 
however it naively tries to execute .lower() on the 
supplied name. If the item does not exist in 
self.dict then it would seem that a KeyError should 
be raised - not AttributeError.

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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-18 13:19

Message:
Logged In: YES 
user_id=6380

In that case I won't fix it. You are only supposed to index
that dict-like object with strings, and if you pass it
anything else you deserve a TypeError, but an AttributeError
will do just fine.

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

Comment By: Martin v. Löwis (loewis)
Date: 2001-09-18 13:12

Message:
Logged In: YES 
user_id=21627

rfc822.Message has an __getitem__ method that matches the 
reported problem.


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

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-06 18:46

Message:
Logged In: YES 
user_id=6380

Ehh???  I don't see a file-like object in urllib2, and I
don't see a __getitem__ method anywhere in the file, and I
don't see a call to .lower() that could be suspect. Which
file are you really talking about? Or can you show a sample
session or program exhibiting the problem?

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

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