Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37501

urllib2 FTP Weirdness

From Nick Cash <nick.cash@npcinternational.com>
Subject urllib2 FTP Weirdness
Date 2013-01-23 20:07 +0000
Newsgroups comp.lang.python
Message-ID <mailman.919.1358971685.2939.python-list@python.org> (permalink)

Show all headers | View raw


Python 2.7.3 on linux

This has me fairly stumped. It looks like
	urllib2.urlopen("ftp://some.ftp.site/path").read()
will either immediately return '' or hang indefinitely. But
	response = urllib2.urlopen("ftp://some.ftp.site/path")
	response.read()
works fine and returns what is expected. This is only an issue with urllib2, vanilla urllib doesn't do it.

The site I first noticed it on is private, but I can reproduce it with "ftp://ftp2.census.gov/".

I've tested the equivalent code on Python 3.2.3 and get the same results, except that one time I got a socket error (may have been a spurious network blip, though). 


I'm at a loss as to how that could even work differently. My only guess is that by not having a reference to the addinfourl response object, something important is getting garbage collected or closed... that seems like a stretch, though. Is this a urllib2 bug, or am I crazy?

-Nick Cash

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

urllib2 FTP Weirdness Nick Cash <nick.cash@npcinternational.com> - 2013-01-23 20:07 +0000
  Re: urllib2 FTP Weirdness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-24 11:41 +1100

csiph-web