[Python-Dev] cpython: Refactor importlib to make it easier to re-implement in C. (original) (raw)
Brett Cannon brett at python.org
Thu Feb 23 17:36:06 CET 2012
- Previous message: [Python-Dev] cpython: Refactor importlib to make it easier to re-implement in C.
- Next message: [Python-Dev] [Python-checkins] peps: Switch back to named functions, since the Ellipsis version degenerated badly
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Feb 23, 2012 at 10:43, Antoine Pitrou <solipsis at pitrou.net> wrote:
On Thu, 23 Feb 2012 16🔞19 +0100 brett.cannon <python-checkins at python.org> wrote: > def sanitycheck(name, package, level): > """Verify arguments are "sane".""" > + if not hasattr(name, 'rpartition'): > + raise TypeError("module name must be str, not {}".format(type(name)))
Why don't you simply use isinstance()? (bytes objects also have rpartition())
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()). -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120223/290a37c6/attachment.html>
- Previous message: [Python-Dev] cpython: Refactor importlib to make it easier to re-implement in C.
- Next message: [Python-Dev] [Python-checkins] peps: Switch back to named functions, since the Ellipsis version degenerated badly
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]