[ python-Bugs-1365984 ] urllib cannot open data: urls

SourceForge.net noreply at sourceforge.net
Fri Nov 25 02:20:52 CET 2005


Bugs item #1365984, was opened at 2005-11-25 12:20
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1365984&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Warren Butler (grumpymole)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib cannot open data: urls

Initial Comment:
Python 2.4.2 cannot open data: urls using open_data().

Appears to be because of importing cStringIO and not
being able to reference fileno.

==============================================
Example fail output:

Traceback (most recent call last):
  File "test_open_data.py", line 6, in ?
    response = opener.open("data:,A%20brief%20note")
  File "/usr/lib/python2.4/urllib.py", line 185, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.4/urllib.py", line 559, in
open_data
    f.fileno = None     # needed for addinfourl
AttributeError: 'cStringIO.StringI' object has no
attribute 'fileno'

==============================================
Example code to generate failure:

import urllib

# data:,A%20brief%20note

opener = urllib.URLopener()
response = opener.open("data:,A%20brief%20note")

==============================================
Note: works in 2.2 version of library.

Problem appears to be here in 2.4:

        import mimetools
        try:
            from cStringIO import StringIO
        except ImportError:
            from StringIO import StringIO

whereas 2.2 reads:

        import StringIO, mimetools, time


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

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


More information about the Python-bugs-list mailing list