This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urllib: Defering open call for file urls
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: doerwalter, gvanrossum
Priority: normal Keywords: patch

Created on 2002-03-05 13:59 by doerwalter, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff.txt doerwalter, 2002-03-05 13:59
Messages (4)
msg39148 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-03-05 13:59
This patch changes the handling of local files in 
urllib.urlopen() and urllib2.urlopen(). Opening the 
file is deferred until the first time read(), readline
(), readlines() or fileno() is called.

This makes it possible to retrieve the header 
information for all URLs via urlopen in a uniform way, 
without actually having to open the file.
msg39149 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-05 14:09
Logged In: YES 
user_id=6380

I don't understand.  Can you explain why you care about
this?
msg39150 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-03-05 14:21
Logged In: YES 
user_id=89016

I'm currently writing a make in Python. This make should be 
able to handle not only local files, but remote files 
(http, ftp, etc.). One project might have several thousand 
targets, and some of them are remote. I want to be able to 
handle both types in a uniform way, i.e. via 
urllib/urllib2. This means, that I call urllib2.urlopen() 
to get the header information about the last modification 
date, but I don't want to open the file right away. Only 
when the data is required (because the source resource is 
newer than the target) should the file be read.

And this might open the door to making streams that are 
returned from urlopen() writable (simply by using open
(..., "wb") instead of open(..., "rb") when the first write 
is called.

Another possibility might be using urllib.urlretrieve(), but
the API is horrible (one global cleanup function) and not 
supported by urllib2.
msg39151 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-07 19:34
Logged In: YES 
user_id=6380

Hm, I don't understand. I can see how you would want to
defer opening *remote* files, because that takes time. But
the patch defers opening *local* files. I still don't
understand what the point of that is.

I think you're trying to generalize in a direction that just
isn't appropriate for urllib. I'm closing this as Rejected,
if you agree with that you don't have to do anything. :-)
History
Date User Action Args
2022-04-10 16:05:04adminsetgithub: 36203
2002-03-05 13:59:29doerwaltercreate