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.

Title: ftplib should accept 250 on MKD
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: giampaolo.rodola Nosy List: alphablue52, eric.smith, giampaolo.rodola, pitrou
Priority: normal Keywords: patch

Created on 2010-08-14 03:41 by alphablue52, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
ftplib-257-workaround.patch giampaolo.rodola, 2010-08-21 16:15
Messages (11)
msg113866 - (view) Author: alphablue52 (alphablue52) Date: 2010-08-14 03:41
I try to use ftplib for a Webspace running on a Windows Server machine.
The server responses 250 instead of 257 (which would be correct according to RFC959, ftp)

It would be nice if ftplib could also tolerate the 250 "Requested file ation okay, completed" code, since I cannot change the server (or beat that M$ programmer).

msg113879 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-08-14 08:37
Since this is a feature request, it could only be added to 3.2, not the other versions.
msg113893 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-14 12:26
> The server responses 250 instead of 257 (which would be correct according to RFC959, ftp)

In response to what command? MKD?
And what do you mean by "tolerate"?
msg114006 - (view) Author: alphablue52 (alphablue52) Date: 2010-08-15 19:57
If you send a "MKD" than Windows Server responses "250", and ftplib generates an Error.
msg114035 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-16 04:50
Where exactly RFC-959 states that 250 is a valid response code for MKD?
Chapter 5.4 reports the following response codes:

  500, 501, 502, 421, 530, 550
msg114131 - (view) Author: alphablue52 (alphablue52) Date: 2010-08-17 16:04
250 is an invalid response to MKD.
M$ Windows Server 2003 does it anyways.
M$ Windows Server is a rather common OS, and there are people like me how have to live with this.

Maybe it should put this into the following words:
"Please make ftplib usuable with M$ Win Server 2003"
msg114135 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-17 16:31
What IIS version are we talking about?
Could you please paste the complete response string other than just the code?
I'm asking this because 257 response is supposed to include the name of the created directory.

Personally I don't like to include workarounds for stupid implementations like this.
If IIS erroneously replies with 250 then maybe it doesn't even include the directory name in which case FTP.mkd method is completely useless for you and you can just work around the exception by using FTP.sendcmd('MKD dirname') instead.
msg114138 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 16:58
Well, given that both replies (expected and actual) are in the 25x category, and that (according to the RFC) “the third digit gives a finer gradation of meaning in each of the function categories, specified by the second digit”, perhaps practicality beats purity and the exact return code isn't that important as long as it falls in the right category.

(what would a Web browser do in that case? say it receives a 201 instead of a 200 or something)

Apparently bzr users hit this bug:
msg114142 - (view) Author: alphablue52 (alphablue52) Date: 2010-08-17 18:27
Jep I also discovered it by using Bazaar, but apparently it goes down to the ftplib. The bazaar fix works, and here is the response of (I use bash ftp):

ftp> open
Connected to
220 Speak friend, and enter
Name (
331 FTP login okay, send password.
230 User logged in, proceed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> mkdir test
250 Directory created.
msg114504 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-21 16:15
Given Antoine comment and the link referencing bzr issue I agree we should fix this now.
A patch including tests for parse257 function is in attachment.
The exception is now raised only if the response code doesn't fall in the 2xx category; for responses != 257 '' is returned.
I'm +1 on including this only in 3.2.
msg114746 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-23 22:11
This is now fixed in r84288.
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53810
2010-08-23 22:11:28giampaolo.rodolasetstatus: open -> closed
assignee: giampaolo.rodola
resolution: fixed
messages: + msg114746
2010-08-21 16:15:14giampaolo.rodolasetfiles: + ftplib-257-workaround.patch
keywords: + patch
messages: + msg114504
2010-08-17 18:27:30alphablue52setmessages: + msg114142
2010-08-17 16:58:13pitrousetnosy: + pitrou
messages: + msg114138
2010-08-17 16:31:28giampaolo.rodolasetmessages: + msg114135
2010-08-17 16:04:18alphablue52setmessages: + msg114131
2010-08-16 04:50:05giampaolo.rodolasetmessages: + msg114035
2010-08-15 19:57:37alphablue52setmessages: + msg114006
2010-08-14 12:26:14giampaolo.rodolasetmessages: + msg113893
2010-08-14 10:15:30pitrousetnosy: + giampaolo.rodola
2010-08-14 08:37:33eric.smithsetversions: - Python 2.6, Python 2.5, Python 3.1, Python 2.7, Python 3.3
nosy: + eric.smith

messages: + msg113879

type: behavior -> enhancement
2010-08-14 03:43:02alphablue52settype: behavior
2010-08-14 03:41:57alphablue52create