summaryrefslogtreecommitdiff
path: root/django/http/request.py
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2014-05-25 22:52:47 +0200
committerFlorian Apolloner <florian@apolloner.eu>2014-06-11 08:57:30 +0200
commite2efc8965edf684aaf48621680ef54b84e116576 (patch)
tree8e33e8db9881b60369831f7fb853be71f5e17960 /django/http/request.py
parenta1c6cd6a167f90fc4dfd76b2a2de87bc617b26e6 (diff)
Fixed #22680 -- I/O operation on closed file.
This patch is two-fold; first it ensure that Django does close everything in request.FILES at the end of the request and secondly the storage system should no longer close any files during save, it's up to the caller to handle that -- or let Django close the files at the end of the request.
Diffstat (limited to 'django/http/request.py')
-rw-r--r--django/http/request.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/http/request.py b/django/http/request.py
index 84457c5300..250db32bf2 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -5,6 +5,7 @@ import os
import re
import sys
from io import BytesIO
+from itertools import chain
from pprint import pformat
from django.conf import settings
@@ -256,6 +257,11 @@ class HttpRequest(object):
else:
self._post, self._files = QueryDict('', encoding=self._encoding), MultiValueDict()
+ def close(self):
+ if hasattr(self, '_files'):
+ for f in chain.from_iterable(l[1] for l in self._files.lists()):
+ f.close()
+
# File-like and iterator interface.
#
# Expects self._stream to be set to an appropriate source of bytes by