Antoine Pitrou <pit...@free.fr> added the comment:

FYI, instead of trying to do exhaustive type checking in _check_type(),
you can just rely on duck typing and catch the TypeError:

>>> str(b"a", "utf-8")
'a'
>>> str(bytearray(b"a"), "utf-8")
'a'
>>> str(memoryview(b"a"), "utf-8")
'a'
>>> str(1, "utf-8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: coercing to str: need string or buffer, int found

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4718>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to