Author: jacob
Date: 2009-05-08 12:22:34 -0500 (Fri, 08 May 2009)
New Revision: 10723

Modified:
   django/trunk/django/core/files/base.py
   django/trunk/django/http/multipartparser.py
   django/trunk/tests/regressiontests/file_uploads/tests.py
Log:
Fixed #10687: fixed request parsing when upload_handlers is empty. Thanks, 
Armin Ronacher.

Modified: django/trunk/django/core/files/base.py
===================================================================
--- django/trunk/django/core/files/base.py      2009-05-08 16:49:49 UTC (rev 
10722)
+++ django/trunk/django/core/files/base.py      2009-05-08 17:22:34 UTC (rev 
10723)
@@ -1,5 +1,4 @@
 import os
-
 try:
     from cStringIO import StringIO
 except ImportError:

Modified: django/trunk/django/http/multipartparser.py
===================================================================
--- django/trunk/django/http/multipartparser.py 2009-05-08 16:49:49 UTC (rev 
10722)
+++ django/trunk/django/http/multipartparser.py 2009-05-08 17:22:34 UTC (rev 
10723)
@@ -84,7 +84,8 @@
 
         # For compatibility with low-level network APIs (with 32-bit integers),
         # the chunk size should be < 2^31, but still divisible by 4.
-        self._chunk_size = min(2**31-4, *[x.chunk_size for x in 
upload_handlers if x.chunk_size])
+        possible_sizes = [x.chunk_size for x in upload_handlers if 
x.chunk_size]
+        self._chunk_size = min([2**31-4] + possible_sizes)
 
         self._meta = META
         self._encoding = encoding or settings.DEFAULT_CHARSET

Modified: django/trunk/tests/regressiontests/file_uploads/tests.py
===================================================================
--- django/trunk/tests/regressiontests/file_uploads/tests.py    2009-05-08 
16:49:49 UTC (rev 10722)
+++ django/trunk/tests/regressiontests/file_uploads/tests.py    2009-05-08 
17:22:34 UTC (rev 10723)
@@ -3,12 +3,14 @@
 import errno
 import shutil
 import unittest
+from StringIO import StringIO
 
 from django.core.files import temp as tempfile
 from django.core.files.uploadedfile import SimpleUploadedFile
 from django.test import TestCase, client
 from django.utils import simplejson
 from django.utils.hashcompat import sha_constructor
+from django.http.multipartparser import MultiPartParser
 
 from models import FileModel, temp_storage, UPLOAD_TO
 import uploadhandler
@@ -290,3 +292,13 @@
                               "%s exists and is not a directory." % UPLOAD_TO)
         except:
             self.fail("IOError not raised")
+
+class MultiParserTests(unittest.TestCase):
+
+    def test_empty_upload_handlers(self):
+        # We're not actually parsing here; just checking if the parser properly
+        # instantiates with empty upload handlers.
+        parser = MultiPartParser({
+            'CONTENT_TYPE':     'multipart/form-data; boundary=_foo',
+            'CONTENT_LENGTH':   '1'
+        }, StringIO('x'), [], 'utf-8')


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to