Marcel Hellkamp added the comment:
This change breaks existing applications.
The cgi.FieldStorage.file attribute is public and mentioned in the
documentation. It even states "You can then read the data at leisure from the
file attribute".
Consider this example::
form = cgi.FieldStorage()
fileitem = form.getfirst("userfile")
if fileitem and fileitem.file:
executor.submit(store_file, fileitem.file, fileitem.filename)
This code is no longer safe. The garbage collector might close the file handle
while it is still referenced and accessed from the worker thread.
Another example is the bottle web framework. It uses cgi.FieldStorage for
parsing only, extracts the valuable information and stores the result in its
own data structures. The cgi.FieldStorage instance is lost. Python 3.4 breaks
every single bottle application that works with file uploads.
How about implementing the context manager protocol for cgi.FieldStorage to
resolve this issue?
----------
nosy: +Marcel.Hellkamp
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18394>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com