From 78fb722abb0efb09ec7d6590b7d1fb68526d7bb3 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Wed, 13 Feb 2019 16:18:42 -0800 Subject: [PATCH] Address some review comments Change-Id: I32a19837f77e8a543994aab18e0f5258b23aeb64 Related-Change: I83aa5d72084ca183e00dc6d69e417fba310a2c59 --- swift/proxy/controllers/base.py | 8 +------- test/unit/proxy/controllers/test_base.py | 5 ++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/swift/proxy/controllers/base.py b/swift/proxy/controllers/base.py index b8f5462332..d9a3a0f5c8 100644 --- a/swift/proxy/controllers/base.py +++ b/swift/proxy/controllers/base.py @@ -857,7 +857,7 @@ class ResumingGetter(object): # we're done with it raise RangeAlreadyComplete() - if end is not None and (begin > end or end < 0): + if end is not None and begin > end: raise HTTPRequestedRangeNotSatisfiable() req_range.ranges = [(begin, end)] + req_range.ranges[1:] @@ -2082,12 +2082,6 @@ class Controller(object): return None, response try: - # We used to let the empty input fall through, where json.loads - # threw and error. Unfortunately, on py3 it throws JSONDecodeError - # that is a pain to catch. So we emulate py2, simple and works - # as long as bodies are not iterators. - if len(response.body) == 0: - raise ValueError('No JSON object could be decoded') data = json.loads(response.body) if not isinstance(data, list): raise ValueError('not a list') diff --git a/test/unit/proxy/controllers/test_base.py b/test/unit/proxy/controllers/test_base.py index 65e661f696..cb47b76e8e 100644 --- a/test/unit/proxy/controllers/test_base.py +++ b/test/unit/proxy/controllers/test_base.py @@ -1120,7 +1120,10 @@ class TestFuncs(unittest.TestCase): def test_get_shard_ranges_empty_body(self): error_lines = self._check_get_shard_ranges_bad_data(b'') self.assertIn('Problem with listing response', error_lines[0]) - self.assertIn('No JSON', error_lines[0]) + if six.PY2: + self.assertIn('No JSON', error_lines[0]) + else: + self.assertIn('JSONDecodeError', error_lines[0]) self.assertFalse(error_lines[1:]) def test_get_shard_ranges_not_a_list(self):