From 1f91189e04dc773d1ae3747fcce8d3b0e25e28d0 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 8 Feb 2017 01:14:01 +0300 Subject: [PATCH] upip: Be sure to close socket if we abort with error early. Need to close properly in more places. --- upip/upip.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/upip/upip.py b/upip/upip.py index 67624f7d..0070fd61 100644 --- a/upip/upip.py +++ b/upip/upip.py @@ -127,6 +127,7 @@ def url_open(url): l = s.readline() protover, status, msg = l.split(None, 2) if status != b"200": + s.close() exc = ValueError(status) if status == b"404": fatal("Package not found", exc) @@ -134,6 +135,7 @@ def url_open(url): while 1: l = s.readline() if not l: + s.close() fatal("Unexpected EOF in HTTP headers", ValueError()) if l == b'\r\n': break