[Python-checkins] r84288 - in python/branches/py3k: Lib/ftplib.py Lib/test/test_ftplib.py Misc/NEWS
giampaolo.rodola
python-checkins at python.org
Tue Aug 24 00:10:33 CEST 2010
Author: giampaolo.rodola
Date: Tue Aug 24 00:10:32 2010
New Revision: 84288
Log:
fix issue 9601: ftplib now provides a workaround for invalid response code returned on MKD and PWD by non-compliant FTPserver implementations such as ISS shipped with Windows server 2003
Modified:
python/branches/py3k/Lib/ftplib.py
python/branches/py3k/Lib/test/test_ftplib.py
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Lib/ftplib.py
==============================================================================
--- python/branches/py3k/Lib/ftplib.py (original)
+++ python/branches/py3k/Lib/ftplib.py Tue Aug 24 00:10:32 2010
@@ -565,7 +565,11 @@
def mkd(self, dirname):
'''Make a directory, return its full pathname.'''
- resp = self.sendcmd('MKD ' + dirname)
+ resp = self.voidcmd('MKD ' + dirname)
+ # fix around non-compliant implementations such as IIS shipped
+ # with Windows server 2003
+ if not resp.startswith('257'):
+ return ''
return parse257(resp)
def rmd(self, dirname):
@@ -574,7 +578,11 @@
def pwd(self):
'''Return current working directory.'''
- resp = self.sendcmd('PWD')
+ resp = self.voidcmd('PWD')
+ # fix around non-compliant implementations such as IIS shipped
+ # with Windows server 2003
+ if not resp.startswith('257'):
+ return ''
return parse257(resp)
def quit(self):
Modified: python/branches/py3k/Lib/test/test_ftplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ftplib.py (original)
+++ python/branches/py3k/Lib/test/test_ftplib.py Tue Aug 24 00:10:32 2010
@@ -606,6 +606,18 @@
self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
self.assertFalse(is_client_connected())
+ def test_parse257(self):
+ self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar')
+ self.assertEqual(ftplib.parse257('257 "/foo/bar" created'), '/foo/bar')
+ self.assertEqual(ftplib.parse257('257 ""'), '')
+ self.assertEqual(ftplib.parse257('257 "" created'), '')
+ self.assertRaises(ftplib.error_reply, ftplib.parse257, '250 "/foo/bar"')
+ # The 257 response is supposed to include the directory
+ # name and in case it contains embedded double-quotes
+ # they must be doubled (see RFC-959, chapter 7, appendix 2).
+ self.assertEqual(ftplib.parse257('257 "/foo/b""ar"'), '/foo/b"ar')
+ self.assertEqual(ftplib.parse257('257 "/foo/b""ar" created'), '/foo/b"ar')
+
class TestIPv6Environment(TestCase):
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Tue Aug 24 00:10:32 2010
@@ -123,8 +123,12 @@
Library
-------
+- Issue #9601: ftplib now provides a workaround for non-compliant
+ implementations such as IIS shipped with Windows server 2003 returning invalid
+ response codes for MKD and PWD commands.
+
- Issue #658749: asyncore's connect() method now correctly interprets winsock
- errors;
+ errors.
- Issue #9501: Fixed logging regressions in cleanup code.
@@ -291,6 +295,8 @@
Tests
-----
+- Issue #9601: Provide a test case for ftplib.parse257.
+
- Issue #8857: Provide a test case for socket.getaddrinfo.
- Issue #7564: Skip test_ioctl if another process is attached to /dev/tty.
More information about the Python-checkins
mailing list