Merge "Address some review comments"

This commit is contained in:
Zuul 2019-02-27 10:34:48 +00:00 committed by Gerrit Code Review
commit 3d4ed23c08
2 changed files with 5 additions and 8 deletions

View File

@ -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')

View File

@ -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):