Mercurial > hg
changeset 41080:9d35ae3d9999
phabricator: ensure that the return of urlopener.open() is closed
No problem observed, just an oversight noticed while reading documentation.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 29 Dec 2018 01:51:02 -0500 |
parents | 88d813cd9acd |
children | 13f50ea8ac3b |
files | hgext/phabricator.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/phabricator.py Thu Dec 20 09:59:16 2018 +0100 +++ b/hgext/phabricator.py Sat Dec 29 01:51:02 2018 -0500 @@ -41,6 +41,7 @@ from __future__ import absolute_import +import contextlib import itertools import json import operator @@ -214,7 +215,8 @@ else: urlopener = urlmod.opener(repo.ui, authinfo) request = util.urlreq.request(url, data=data) - body = urlopener.open(request).read() + with contextlib.closing(urlopener.open(request)) as rsp: + body = rsp.read() repo.ui.debug(b'Conduit Response: %s\n' % body) parsed = json.loads(body) if parsed.get(r'error_code'):