mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
#1664522: in urllib, don't read non-existing directories in ftp mode,
returning a 0-byte file -- raise an IOError instead. Original patch from Phil Knirsch.
This commit is contained in:
parent
2235011d49
commit
d5e6cf2b15
2 changed files with 16 additions and 3 deletions
|
@ -872,9 +872,19 @@ class ftpwrapper:
|
||||||
if not conn:
|
if not conn:
|
||||||
# Set transfer mode to ASCII!
|
# Set transfer mode to ASCII!
|
||||||
self.ftp.voidcmd('TYPE A')
|
self.ftp.voidcmd('TYPE A')
|
||||||
# Try a directory listing
|
# Try a directory listing. Verify that directory exists.
|
||||||
if file: cmd = 'LIST ' + file
|
if file:
|
||||||
else: cmd = 'LIST'
|
pwd = self.ftp.pwd()
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
self.ftp.cwd(file)
|
||||||
|
except ftplib.error_perm, reason:
|
||||||
|
raise IOError, ('ftp error', reason), sys.exc_info()[2]
|
||||||
|
finally:
|
||||||
|
self.ftp.cwd(pwd)
|
||||||
|
cmd = 'LIST ' + file
|
||||||
|
else:
|
||||||
|
cmd = 'LIST'
|
||||||
conn = self.ftp.ntransfercmd(cmd)
|
conn = self.ftp.ntransfercmd(cmd)
|
||||||
self.busy = 1
|
self.busy = 1
|
||||||
# Pass back both a suitably decorated object and a retrieval length
|
# Pass back both a suitably decorated object and a retrieval length
|
||||||
|
|
|
@ -369,6 +369,9 @@ Core and builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- #1664522: in urllib, don't read non-existing directories in ftp mode,
|
||||||
|
returning a 0-byte file -- raise an IOError instead.
|
||||||
|
|
||||||
- #856047: respect the ``no_proxy`` environment variable when using the
|
- #856047: respect the ``no_proxy`` environment variable when using the
|
||||||
``http_proxy`` etc. environment variables in urllib.
|
``http_proxy`` etc. environment variables in urllib.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue