Skip to content

Commit

Permalink
JSONDecodeError -> ValueError
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Mangled Deutz <[email protected]> (github: dmp42)
  • Loading branch information
Mangled Deutz committed May 19, 2014
1 parent d2fc1c4 commit 4757a0c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docker_registry/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def put_image_json(image_id):
try:
# Note(dmp): unicode patch
data = json.loads(flask.request.data.decode('utf8'))
except json.JSONDecodeError:
except ValueError:
pass
if not data or not isinstance(data, dict):
return toolkit.api_error('Invalid JSON')
Expand Down
4 changes: 2 additions & 2 deletions docker_registry/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_post_users():
try:
# Note(dmp): unicode patch
json.loads(flask.request.data.decode('utf8'))
except json.JSONDecodeError:
except ValueError:
return toolkit.api_error('Error Decoding JSON', 400)
return toolkit.response('User Created', 201)

Expand Down Expand Up @@ -106,7 +106,7 @@ def put_repository(namespace, repository, images=False):
try:
# Note(dmp): unicode patch
data = json.loads(flask.request.data.decode('utf8'))
except json.JSONDecodeError:
except ValueError:
return toolkit.api_error('Error Decoding JSON', 400)
if not isinstance(data, list):
return toolkit.api_error('Invalid data')
Expand Down
4 changes: 2 additions & 2 deletions docker_registry/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def set_properties(namespace, repo):
try:
# Note(dmp): unicode patch
data = json.loads(flask.request.data.decode('utf8'))
except json.JSONDecodeError:
except ValueError:
pass
if not data or not isinstance(data, dict):
return toolkit.api_error('Invalid data')
Expand Down Expand Up @@ -180,7 +180,7 @@ def put_tag(namespace, repository, tag):
try:
# Note(dmp): unicode patch
data = json.loads(flask.request.data.decode('utf8'))
except json.JSONDecodeError:
except ValueError:
pass
if not data or not isinstance(data, basestring):
return toolkit.api_error('Invalid data')
Expand Down
4 changes: 2 additions & 2 deletions docker_registry/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def validate_parent_access(parent_id):
# Note(dmp): unicode patch XXX not applied! Assuming requests does it
logger.debug('validate_parent: Content: {0}'.format(resp.text))
return json.loads(resp.text).get('access', False)
except json.JSONDecodeError:
except ValueError:
logger.debug('validate_parent: Wrong response format')
return False

Expand Down Expand Up @@ -154,7 +154,7 @@ def validate_token(auth):
images_list = [i['id'] for i in json.loads(resp.text)]
store.put_content(store.images_list_path(*full_repos_name),
json.dumps(images_list))
except json.JSONDecodeError:
except ValueError:
logger.debug('validate_token: Wrong format for images_list')
return False
return True
Expand Down

0 comments on commit 4757a0c

Please sign in to comment.