New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In python 3.4 multipart file upload breaks due to change in cgi.FieldStorage #567
Comments
http://bugs.python.org/issue18394 If they do not fix this, we have to. Your workaround looks ok. |
Looks like a wont-fix, so we have to. |
jklp
added a commit
to bluecottagesoftware/watson-http
that referenced
this issue
Jul 22, 2015
Due to a bug in python 3.4 and the FieldStorage object (bottlepy/bottle#567 / http://bugs.python.org/issue18394), looks like watson.http.messages.Request is unwrapping FieldStorage and returning it into a “files” tuple. The unwrapping is causing the del to be called and closing the file - which means uploaded files can't be read.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Python 3.4, the
cgi.FileStorage
class now has a__del__
method that close the file objects.BaseRequest.POST()
uses that class to parse multipart requests and then grabs the files directly intoFileUpload
instances. When the function exits, the variable data is garbage collected and the__del__
method is called, closing the file handle held in the returnedpost
dictionary.Unit test
test_environ.test_multipart()
catches this because it tries to access the file object andread()
s it which fails with this exception:This doesn't happen in python 3.3.3.
I'm not sure the best way to go around fixing this. Perhaps stashing the
cgi.FileStorage
instance in the returnpost
dictionary? That would fix the dereference but it's ugly:The text was updated successfully, but these errors were encountered: