[Patches] [Patch #102808] Export control for modules
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 10 Jan 2001 11:17:22 -0800
Patch #102808 has been updated.
Project: python
Category: core (C code)
Status: Rejected
Submitted by: rumjuggler
Assigned to : gvanrossum
Summary: Export control for modules
Follow-Ups:
Date: 2001-Jan-10 11:17
By: gvanrossum
Comment:
Rejected based on extensive discussion in python-dev.
We'll implement __all__ however; this will be used only by "from...import
*".
Thanks for getting this discussion started!
-------------------------------------------------------
Date: 2001-Jan-07 08:14
By: greg_ball
Comment:
How about an alternative syntax: assignment to module.__dict__ (currently
not allowed.)
# module foo.py
constant_number=3
def bar():
print constant_number
import foo
foo.__dict__={'bar':bar}
# end of module foo
Now attribute access can get only the objects
in the new dict. However if you really want to,
you can access
foo.bar.func_globals
since functions defined in foo keep a reference
to their oringinal namespace. (otherwise this proposal would just break
everything...)
-------------------------------------------------------
Date: 2001-Jan-05 21:40
By: nobody
Comment:
Shouldn't it be called "__all__" (for consistency with a similar
functionality in packages)?
-------------------------------------------------------
Date: 2001-Jan-05 13:20
By: tim_one
Comment:
+1 on the idea, -1 on the patch. If PyModule_ExportableName is supposed to
be a new part of the public API, we need docs for it; else it should be
renamed (with a leading underscore).
If it is part of the public API, it needs to sanity-check its arguments
(e.g., at least that m and s aren't NULL -- we'll get a core dump now if
they are); else it should at least assert that they're sane.
Needs a test in any case.
-------------------------------------------------------
Date: 2000-Dec-13 05:55
By: gvanrossum
Comment:
Original title was: """modules w/ vbl "__exports__" (lst of strs) have
access ctrl."""
This implements an interesting way of which names are visible outside the
module that defines it: the __exports__ variable contains a list of
exported names. If it is present, any name not in __exports__ is not
accessible from outside the module (neither through import nor through
direct access (getattr/setattr).
-------------------------------------------------------
-------------------------------------------------------
For more info, visit:
http://sourceforge.net/patch/?func=detailpatch&patch_id=102808&group_id=5470