[issue21720] "TypeError: Item in ``from list'' not a string" message

Nick Coghlan report at bugs.python.org
Wed Oct 25 05:04:00 EDT 2017


Nick Coghlan <ncoghlan at gmail.com> added the comment:

I'm fine with the approach in the latest version of the PR - it does make "from x import y" slightly slower due to the extra error checking, but folks should be avoiding doing that in performance critical loops or functions anyway.

It would be nice if we could avoid that overhead for the import statement case, but we can't readily tell the difference between "__import__ called via syntax" and "__import__ called directly", and I don't think this is going to be performance critical enough to be worth introducing that complexity.

The question of how best to handle passing a consumable iterator as the from list would be a separate question, if we decided to do anything about it at all (the current implementation implicitly assumes the input is reiterable, but passing a non-container seems like a harder mistake to make than accidentally passing bytes instead of a string).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue21720>
_______________________________________


More information about the Python-bugs-list mailing list