Message278527
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 :)) |
|
Date |
User |
Action |
Args |
2016-10-12 10:48:55 | berker.peksag | set | recipients:
+ berker.peksag, brett.cannon, rhettinger, ncoghlan, ezio.melotti, bignose, eric.snow, serhiy.storchaka, Julian.Gindi, davidszotten@gmail.com, Tim.Graham |
2016-10-12 10:48:55 | berker.peksag | set | messageid: <1476269335.08.0.693613646036.issue21720@psf.upfronthosting.co.za> |
2016-10-12 10:48:55 | berker.peksag | link | issue21720 messages |
2016-10-12 10:48:54 | berker.peksag | create | |
|