Berker Peksag added the comment:

Well, I find using a for loop is a bit verbose in this case :)

In Python 3.2:

>>> __import__('encodings', fromlist=[b'aliases'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Item in ``from list'' not a string

BytesWarning is there since Python 3.3 and I couldn't find any report on the 
tracker. I'd be fine with either committing the current patch or using 
pre-importlib exception message from 3.2 in 3.5+ (assuming the chance of 
passing a non-str item is low in Python 3)

> Other solution for Python 2 is allowing unicode in fromlist.

My preference is to improve the exception message and move on. Accepting both 
str and unicode would make the code harder to maintain and it would be better 
to avoid potential regressions in 2.7 (note that we already introduced 
regressions in the previous bugfix releases :))


Python tracker <>
Python-bugs-list mailing list

Reply via email to