Skip to content

Commit

Permalink
Minor changes based on lessons learned from quodlibet#321
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Aug 26, 2017
1 parent 8fe2946 commit 521f195
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mutagen/aiff.py
Expand Up @@ -39,8 +39,14 @@ class InvalidChunk(error):
def is_valid_chunk_id(id):
assert isinstance(id, text_type)

return ((len(id) <= 4) and (min(id) >= u' ') and
(max(id) <= u'~'))
if len(id) < 1 or len(id) > 4:
return False

for i in range(0, len(id)):
if id[i] < u' ' or id[i] > u'~':
return False

return True


def read_float(data): # 10 bytes
Expand Down Expand Up @@ -170,7 +176,7 @@ def __contains__(self, id_):
assert isinstance(id_, text_type)

if not is_valid_chunk_id(id_):
raise KeyError("AIFF key must be four ASCII characters.")
raise ValueError("AIFF key must be four ASCII characters.")

return id_ in self.__chunks

Expand Down

0 comments on commit 521f195

Please sign in to comment.