[issue32932] better error message when __all__ contains non-str objects

2018-03-24 Thread Xiang Zhang
Change by Xiang Zhang : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___ Py

[issue32932] better error message when __all__ contains non-str objects

2018-03-24 Thread Xiang Zhang
Xiang Zhang added the comment: New changeset d8b291a74284307610946f1b5801aa95d7f1e052 by Xiang Zhang in branch 'master': bpo-32932: More revealing error message when non-str objects in __all__ (GH-5848) https://github.com/python/cpython/commit/d8b291a74284307610946f1b5801aa95d7f1e052 --

[issue32932] better error message when __all__ contains non-str objects

2018-02-27 Thread Xiang Zhang
Xiang Zhang added the comment: I would like the error message improved. The Python message is obviously much better than the C message. It sends the cause to your eyes. Different messages issued from similar statements are confusing. And due to the non-ideal message is generated by C, the tra

[issue32932] better error message when __all__ contains non-str objects

2018-02-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I was fooled by similarity of Python and C code, but actually Python and C code are not different implementations of the same algorithm, they have different purposes. The purpose of _bootstrap._handle_fromlist() is importing requested submodules first than

[issue32932] better error message when __all__ contains non-str objects

2018-02-26 Thread Nick Coghlan
Nick Coghlan added the comment: I +1'ed Serhiy's patch for issue 32946, so we'll have to take that micro-optimisation into account if we decide to rely on the Python level `_handle_fromlist` to cover the "*" import case. Given that optimisation, it's probably simpler to just enhance the C err

[issue32932] better error message when __all__ contains non-str objects

2018-02-25 Thread Brett Cannon
Brett Cannon added the comment: This is only for `import *`, though, right? So I would argue you're already tossing import perf out the window if you're willing to pollute your namespace like that. -- ___ Python tracker

[issue32932] better error message when __all__ contains non-str objects

2018-02-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: On other hand, adding checks in Python code will add a slowdown. See issue32946 which moves in contrary direction. -- ___ Python tracker __

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Nick Coghlan
Nick Coghlan added the comment: I believe the original rationale for the `__path__` check was to restrict that branch to the case where we may need to import a not-yet-imported submodule in order to get the attribute set appropriately. However, giving a better error message for __all__ in ord

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I was wondering why the error is not raised by the IMPORT_NAME opcode which predates IMPORT_FROM. It calls _handle_fromlist() from _bootstrap. But in this case the module doesn't have the __path__ attribute and the sanity check was skipped. I'm wondering i

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Brett Cannon
Brett Cannon added the comment: Fixing the message makes sense. I assume this is happening in ceval.c or import.c since https://github.com/python/cpython/blob/42c35d9c0c8175332f50fbe034a001fe52f057b9/Lib/importlib/_bootstrap.py#L1021 has the appropriate message? -- nosy: +barry

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Added import experts since this issue can be not so trivial as looked at first glance. -- nosy: +brett.cannon, eric.snow, ncoghlan ___ Python tracker _

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Xiang Zhang
Change by Xiang Zhang : -- keywords: +patch pull_requests: +5624 stage: needs patch -> patch review ___ Python tracker ___ ___ Python

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Agreed. Seems this was an oversight. Do you want to write a patch yourself or left it on to me? -- nosy: +serhiy.storchaka stage: -> needs patch ___ Python tracker __

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Xiang Zhang
Xiang Zhang added the comment: s/AttributeError/TypeError -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue32932] better error message when __all__ contains non-str objects

2018-02-24 Thread Xiang Zhang
New submission from Xiang Zhang : I see people wrongly write non-str objects in __all__ and the error message for this case is simply a AttributeError which doesn't reveal the cause directly. >>> from test import * Traceback (most recent call last): File "", line 1, in TypeError: attribute n