CGI POST binary file upload?

Fredrik Lundh fredrik at effbot.org
Wed Dec 6 15:55:50 EST 2000


Ilariu Raducan wrote:
> It's true mode='rb' should be the default parameter in the function call
> only when the OS is windows.

What are you talking about?

makefile is a method in the standard library, which takes
an optional mode argument.  If you don't like the default
value, to pass in a better value (e.g. "rb") when you
*call* the method.

In other words, replace:

    myfile = mysocket.makefile()

with

    myfile = mysocket.makefile("rb")

(All network modules in the standard library do this when
necessary, so why cannot you?)

Your so-called "fix" changed makefile to completely ignore the
mode argument.  As a result, you'll break any code that passes
in something other than "rb" (like any code using the Socket-
Server's wfile attribute, including BaseHTTPServer, and others).

</F>







More information about the Python-list mailing list