Skip to content

Commit

Permalink
Fix coderize not to recognize a str object as a coder in py2
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Nov 26, 2017
1 parent e28fbca commit 996f500
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ring/coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ def coderize(raw_coder):
if isinstance(raw_coder, Coder):
coder = raw_coder
else:
if isinstance(raw_coder, str): # py2 support
raise TypeError(
"The given coder is not a registered name in coder registry.")
if isinstance(raw_coder, tuple):
coder = CoderTuple(*raw_coder)
elif hasattr(raw_coder, 'encode') and hasattr(raw_coder, 'decode'):
coder = CoderTuple(raw_coder.encode, raw_coder.decode)
else:
raise TypeError("The given coder is not compatibile to Coder")
raise TypeError(
"The given coder is not a coder compatibile object or "
"not a registered name in coder registry")
return coder


Expand Down

0 comments on commit 996f500

Please sign in to comment.