Nick Coghlan added the comment:

Berker's fix for Python 2.7 looks good to me.

However, Python 3 has a comparably vague error message, it's just inverted to 
complain about bytes rather than unicode due to the change in the native str 
type:

>>> __import__('encodings', fromlist=[b'aliases'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1013, in _handle_fromlist
TypeError: hasattr(): attribute name must be string

hasattr() in Python 2.7 is similarly unhelpful regarding what type it actually 
got when you give it something it doesn't expect.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21720>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to