[Python-modules-commits] [python-django] 03/03: New upstream bugfix release.

Raphaël Hertzog hertzog at moszumanska.debian.org
Wed Jan 28 09:18:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

hertzog pushed a commit to branch debian/experimental
in repository python-django.

commit 68051874fbde0ddddf1c8c26d540d45241b949ca
Author: Raphaël Hertzog <hertzog at debian.org>
Date:   Wed Jan 28 09:38:37 2015 +0100

    New upstream bugfix release.
    
    Drop fix-24193-python34-test-failure.diff, merged upstream.
---
 debian/changelog                                   |   7 ++
 .../patches/fix-24193-python34-test-failure.diff   | 124 ---------------------
 debian/patches/series                              |   1 -
 3 files changed, 7 insertions(+), 125 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index f25fff9..01394cf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python-django (1.7.4-1~exp1) experimental; urgency=medium
+
+  * New upstream bugfix release.
+  * Drop fix-24193-python34-test-failure.diff, merged upstream.
+
+ -- Raphaël Hertzog <hertzog at debian.org>  Wed, 28 Jan 2015 09:38:24 +0100
+
 python-django (1.7.3-1~exp1) experimental; urgency=high
 
   [ Luke Faraone ]
diff --git a/debian/patches/fix-24193-python34-test-failure.diff b/debian/patches/fix-24193-python34-test-failure.diff
deleted file mode 100644
index d3f0c4d..0000000
--- a/debian/patches/fix-24193-python34-test-failure.diff
+++ /dev/null
@@ -1,124 +0,0 @@
-Author: Claude Paroz <claude at 2xlibre.net>
-Date:   Wed Jan 21 20:59:40 2015 +0100
-
-    [1.7.x] Fixed #24193 -- Prevented unclosed file warnings in static.serve()
-    
-    This regression was caused by 818e59a3f0. The patch is a partial
-    backport of the new FileResponse class available in later Django
-    versions.
-    Thanks Raphaël Hertzog for the report, and Tim Graham and Collin
-    Anderson for the reviews.
-
-Origin: upstream, https://github.com/django/django/commit/b1bf8d64fbadcab860eb98662c49b8db33db0c3c
-Applied-Upstream: 1.7.4
-Bug: https://code.djangoproject.com/ticket/24193
-
---- a/django/http/__init__.py
-+++ b/django/http/__init__.py
-@@ -1,7 +1,8 @@
- from django.http.cookie import SimpleCookie, parse_cookie
- from django.http.request import (HttpRequest, QueryDict,
-     RawPostDataException, UnreadablePostError, build_request_repr)
--from django.http.response import (HttpResponse, StreamingHttpResponse,
-+from django.http.response import (
-+    HttpResponse, StreamingHttpResponse, FileResponse,
-     HttpResponseRedirect, HttpResponsePermanentRedirect,
-     HttpResponseNotModified, HttpResponseBadRequest, HttpResponseForbidden,
-     HttpResponseNotFound, HttpResponseNotAllowed, HttpResponseGone,
-@@ -16,5 +17,5 @@ __all__ = [
-     'HttpResponseBadRequest', 'HttpResponseForbidden', 'HttpResponseNotFound',
-     'HttpResponseNotAllowed', 'HttpResponseGone', 'HttpResponseServerError',
-     'Http404', 'BadHeaderError', 'fix_location_header', 'JsonResponse',
--    'conditional_content_removal',
-+    'FileResponse', 'conditional_content_removal',
- ]
---- a/django/http/response.py
-+++ b/django/http/response.py
-@@ -382,6 +382,9 @@ class StreamingHttpResponse(HttpResponse
- 
-     @streaming_content.setter
-     def streaming_content(self, value):
-+        self._set_streaming_content(value)
-+
-+    def _set_streaming_content(self, value):
-         # Ensure we can never iterate on "value" more than once.
-         self._iterator = iter(value)
-         if hasattr(value, 'close'):
-@@ -391,6 +394,21 @@ class StreamingHttpResponse(HttpResponse
-         return self.streaming_content
- 
- 
-+class FileResponse(StreamingHttpResponse):
-+    """
-+    A streaming HTTP response class optimized for files.
-+    """
-+    block_size = 4096
-+
-+    def _set_streaming_content(self, value):
-+        if hasattr(value, 'read'):
-+            self._iterator = iter(lambda: value.read(self.block_size), b'')
-+            if hasattr(value, 'close'):
-+                self._closable_objects.append(value)
-+        else:
-+            super(FileResponse, self)._set_streaming_content(value)
-+
-+
- class HttpResponseRedirectBase(HttpResponse):
-     allowed_schemes = ['http', 'https', 'ftp']
- 
---- a/django/views/static.py
-+++ b/django/views/static.py
-@@ -11,14 +11,12 @@ import posixpath
- import re
- 
- from django.http import (Http404, HttpResponse, HttpResponseRedirect,
--    HttpResponseNotModified, StreamingHttpResponse)
-+    HttpResponseNotModified, FileResponse)
- from django.template import loader, Template, Context, TemplateDoesNotExist
- from django.utils.http import http_date, parse_http_date
- from django.utils.six.moves.urllib.parse import unquote
- from django.utils.translation import ugettext as _, ugettext_lazy
- 
--STREAM_CHUNK_SIZE = 4096
--
- 
- def serve(request, path, document_root=None, show_indexes=False):
-     """
-@@ -63,9 +61,7 @@ def serve(request, path, document_root=N
-         return HttpResponseNotModified()
-     content_type, encoding = mimetypes.guess_type(fullpath)
-     content_type = content_type or 'application/octet-stream'
--    f = open(fullpath, 'rb')
--    response = StreamingHttpResponse(iter(lambda: f.read(STREAM_CHUNK_SIZE), b''),
--                                     content_type=content_type)
-+    response = FileResponse(open(fullpath, 'rb'), content_type=content_type)
-     response["Last-Modified"] = http_date(statobj.st_mtime)
-     if stat.S_ISREG(statobj.st_mode):
-         response["Content-Length"] = statobj.st_size
---- a/tests/view_tests/tests/test_static.py
-+++ b/tests/view_tests/tests/test_static.py
-@@ -5,10 +5,10 @@ from os import path
- import unittest
- 
- from django.conf.urls.static import static
--from django.http import HttpResponseNotModified
-+from django.http import FileResponse, HttpResponseNotModified
- from django.test import SimpleTestCase, override_settings
- from django.utils.http import http_date
--from django.views.static import was_modified_since, STREAM_CHUNK_SIZE
-+from django.views.static import was_modified_since
- 
- from .. import urls
- from ..urls import media_dir
-@@ -37,9 +37,10 @@ class StaticTests(SimpleTestCase):
-         "The static view should stream files in chunks to avoid large memory usage"
-         response = self.client.get('/%s/%s' % (self.prefix, 'long-line.txt'))
-         first_chunk = next(response.streaming_content)
--        self.assertEqual(len(first_chunk), STREAM_CHUNK_SIZE)
-+        self.assertEqual(len(first_chunk), FileResponse.block_size)
-         second_chunk = next(response.streaming_content)
-         self.assertEqual(len(second_chunk), 1451)
-+        response.close()
- 
-     def test_unknown_mime_type(self):
-         response = self.client.get('/%s/file.unknown' % self.prefix)
diff --git a/debian/patches/series b/debian/patches/series
index fcd2e9c..c73a668 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,3 @@
 02_disable-sources-in-sphinxdoc.diff
 03_manpage.diff
 06_use_debian_geoip_database_as_default.diff
-fix-24193-python34-test-failure.diff

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django.git



More information about the Python-modules-commits mailing list