This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Allow set/frozenset for __all__
Type: enhancement Stage:
Components: Versions: Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Rhamphoryncus, georg.brandl, rhettinger
Priority: normal Keywords: patch

Created on 2008-05-20 06:01 by Rhamphoryncus, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-importall.diff Rhamphoryncus, 2008-05-20 06:01
Messages (6)
msg67104 - (view) Author: Adam Olsen (Rhamphoryncus) Date: 2008-05-20 06:01
Patch allows any iterable (such as set and frozenset) to be used for
__all__.

I also add some blank lines, making it more readable.
msg67112 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-05-20 08:06
Does this break code that adds to __all__ using append() and extend()?  
See the os module for an example.
msg67114 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-20 08:13
You don't check for NULL return from PyObject_GetIter(). It will
segfault for "__all__ = 1".

That demonstrates that test cases are missing from the patch. :)

Raymond: It shouldn't since __all__ is only inspected after the module
code has been executed.
msg67115 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-05-20 08:24
The breakage isn't from the patch.  The problem would come from using a 
non-list iterable for __all__ which then breaks any other code that 
assumes __all__ is a list (the code is os is an example of how __all__ 
can get modified).  

AFAICT, this proposal doesn't add value, but it does complicate life 
for those wanting to access/modify __all__ but can no longer make 
assumptions about its type (perhaps it is a generator that can be read 
just once and any accessor would kill it in the process of examining 
it).  I don't see how this proposal adds value.  It's just a random 
change that doesn't make life any better for coders.
msg67119 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-20 08:45
I agree. There seems to be no compelling use case.
msg67135 - (view) Author: Adam Olsen (Rhamphoryncus) Date: 2008-05-20 18:18
tuples are already allowed for __all__, which breaks attempts to
monkey-patch it.

I did forget to check the return from PyObject_GetIter.
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47177
2008-05-20 18:18:51Rhamphoryncussetmessages: + msg67135
2008-05-20 09:15:33rhettingersetstatus: open -> closed
resolution: rejected
2008-05-20 08:45:32georg.brandlsetmessages: + msg67119
2008-05-20 08:25:25rhettingersetmessages: + msg67115
2008-05-20 08:13:11georg.brandlsetnosy: + georg.brandl
messages: + msg67114
2008-05-20 08:07:06rhettingersetassignee: rhettinger
type: enhancement
messages: + msg67112
nosy: + rhettinger
versions: + Python 2.6
2008-05-20 06:01:38Rhamphoryncuscreate