Nick Coghlan added the comment:

@Berker: the warning under "-bb" is a separate issue related to the handling of 
wildcard imports (_handle_fromlist searches for '*' and then pops it from a 
copy of the input list, replacing it with __all__ if that's defined)

@Ben: As a general principle, we don't give value information in type errors, 
since the error is structural rather than value based. The closest equivalent 
to us doing that that I'm aware of is the sequence index being given in 
str.join's TypeError:

    >>> "".join(["a", "b", b"c"])
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: sequence item 2: expected str instance, bytes found

By contrast, when sorting, we don't give *any* indication as to where in the 
sequence the problem was found or the specific values involved:

    >>> sorted(["a", "b", b"c"])
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: unorderable types: bytes() < str()

That doesn't make it a bad idea (as I think you're right that it would often 
make debugging easier), I'd just prefer to consider that as a separate question 
rather than introducing a one-off inconsistency with the general policy here 
(in particular, encountering TypeError is far more likely with str.join and 
sorted than it is with __import__, so it would be genuinely weird for the 
latter to have the most helpful error message).


Python tracker <>
Python-bugs-list mailing list

Reply via email to