Skip to content

Commit 919bfc7

Browse files
committed
raise more specific error message if argument to to_unicode() is neither unicode nor str
1 parent 5110561 commit 919bfc7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

oauth2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def to_unicode(s):
9292
""" Convert to unicode, raise exception with instructive error
9393
message if s is not unicode or ascii. """
9494
if not isinstance(s, unicode):
95+
if not isinstance(s, str):
96+
raise TypeError('You are required to pass either unicode or string here, not: %r (%s)' % (type(s), s))
9597
try:
9698
s = s.decode('ascii')
9799
except UnicodeDecodeError, le:

0 commit comments

Comments
 (0)