summaryrefslogtreecommitdiff
path: root/dummyserver
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2016-09-05 17:05:09 +0100
committerCory Benfield <lukasaoz@gmail.com>2016-09-05 17:05:09 +0100
commite5fb9777b71b2f141b903236d233a5592e620f14 (patch)
treee60501083391630052f6e26172e2ca4e857672fc /dummyserver
parent4a68c533b79c4e3ddec8e451b1091d4000c5b69f (diff)
parent41259f3ae6bbf0c2fc1ff87a1b2c403d80057a06 (diff)
downloadurllib3-e5fb9777b71b2f141b903236d233a5592e620f14.tar.gz
Merge branch 'close' of https://github.com/scop/urllib3 into scop-close
Diffstat (limited to 'dummyserver')
-rw-r--r--dummyserver/handlers.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/dummyserver/handlers.py b/dummyserver/handlers.py
index d72a6bdd..2c47a814 100644
--- a/dummyserver/handlers.py
+++ b/dummyserver/handlers.py
@@ -1,6 +1,7 @@
from __future__ import print_function
import collections
+import contextlib
import gzip
import json
import logging
@@ -199,9 +200,8 @@ class TestingApp(RequestHandler):
if encoding == 'gzip':
headers = [('Content-Encoding', 'gzip')]
file_ = BytesIO()
- zipfile = gzip.GzipFile('', mode='w', fileobj=file_)
- zipfile.write(data)
- zipfile.close()
+ with contextlib.closing(gzip.GzipFile('', mode='w', fileobj=file_)) as zipfile:
+ zipfile.write(data)
data = file_.getvalue()
elif encoding == 'deflate':
headers = [('Content-Encoding', 'deflate')]