<br><br><div class="gmail_quote">On Thu, Feb 23, 2012 at 10:43, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net">solipsis@pitrou.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, 23 Feb 2012 16:18:19 +0100<br>
brett.cannon <<a href="mailto:python-checkins@python.org">python-checkins@python.org</a>> wrote:<br>
> def _sanity_check(name, package, level):<br>
> """Verify arguments are "sane"."""<br>
> + if not hasattr(name, 'rpartition'):<br>
> + raise TypeError("module name must be str, not {}".format(type(name)))<br>
<br>
</div>Why don't you simply use isinstance()?<br>
(bytes objects also have rpartition())<br></blockquote><div><br></div><div>I think I was on a interface-conformance kick at the time and didn't want to restrict to a specific type over a specific interface. But since subclasses is not exactly complicated I can change this (which will also match potential C code more with a PyUnicode_Check()). </div>