[Python-checkins] cpython (3.4): Try to transfer the Unicode test data files gzipped.

georg.brandl python-checkins at python.org
Thu Nov 6 15:33:48 CET 2014


https://hg.python.org/cpython/rev/540b022ae7a9
changeset:   93419:540b022ae7a9
branch:      3.4
parent:      93415:39536b377241
user:        Georg Brandl <georg at python.org>
date:        Thu Nov 06 15:33:30 2014 +0100
summary:
  Try to transfer the Unicode test data files gzipped.

files:
  Lib/test/support/__init__.py |  7 ++++++-
  1 files changed, 6 insertions(+), 1 deletions(-)


diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1029,7 +1029,12 @@
     requires('urlfetch')
 
     print('\tfetching %s ...' % url, file=get_original_stdout())
-    f = urllib.request.urlopen(url, timeout=15)
+    opener = urllib.request.build_opener()
+    if gzip:
+        opener.addheaders.append(('Accept-Encoding', 'gzip'))
+    f = opener.open(url, timeout=15)
+    if gzip and f.headers.get('Content-Encoding') == 'gzip':
+        f = gzip.GzipFile(fileobj=f)
     try:
         with open(fn, "wb") as out:
             s = f.read()

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list