From 1497086039010dab67c7a405e815afa5387a627b Mon Sep 17 00:00:00 2001 From: Kuppuswamy Sathyanarayanan Date: Thu, 19 Jul 2018 22:22:18 -0700 Subject: [PATCH] jsonschema: Fix non http/https url RefResolution exception When using file:///schema-dir-name URLs we are hitting AttributeError exception during refresolution. Reason for it is, there isn't any context manager implemented for urlopen (i.e. it doesn't have __enter__ and __exit__ methods defined). This patch fixes this issue. Signed-off-by: Kuppuswamy Sathyanarayanan --- jsonschema/validators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 28f2f6f8f..f05a6c9f5 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -755,8 +755,8 @@ def resolve_remote(self, uri): result = requests.get(uri).json else: # Otherwise, pass off to urllib and assume utf-8 - with urlopen(uri) as url: - result = json.loads(url.read().decode("utf-8")) + url = urlopen(uri) + result = json.loads(url.read().decode("utf-8")) if self.cache_remote: self.store[uri] = result