summaryrefslogtreecommitdiffstats
path: root/Doc/ref
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2006-06-10 20:01:34 (GMT)
committerFred Drake <fdrake@acm.org>2006-06-10 20:01:34 (GMT)
commit5e30626f7fcafeb6356f38b7a84e664f4ba13564 (patch)
tree957ec768a6a31580ca2a1bd0bdb6e1d6a2e0b4f8 /Doc/ref
parent51148269507e884c082593f30f178faafb54e60d (diff)
downloadcpython-5e30626f7fcafeb6356f38b7a84e664f4ba13564.zip
cpython-5e30626f7fcafeb6356f38b7a84e664f4ba13564.tar.gz
cpython-5e30626f7fcafeb6356f38b7a84e664f4ba13564.tar.bz2
SF patch #1303595: improve description of __builtins__, explaining how it
varies between __main__ and other modules, and strongly suggest not touching it but using __builtin__ if absolutely necessary
Diffstat (limited to 'Doc/ref')
-rw-r--r--Doc/ref/ref4.tex18
1 files changed, 14 insertions, 4 deletions
diff --git a/Doc/ref/ref4.tex b/Doc/ref/ref4.tex
index dcdc823..12a2b92 100644
--- a/Doc/ref/ref4.tex
+++ b/Doc/ref/ref4.tex
@@ -97,10 +97,20 @@ searched. The global statement must precede all uses of the name.
The built-in namespace associated with the execution of a code block
is actually found by looking up the name \code{__builtins__} in its
global namespace; this should be a dictionary or a module (in the
-latter case the module's dictionary is used). Normally, the
-\code{__builtins__} namespace is the dictionary of the built-in module
-\module{__builtin__} (note: no `s'). If it isn't, restricted
-execution\indexii{restricted}{execution} mode is in effect.
+latter case the module's dictionary is used). By default, when in the
+\module{__main__} module, \code{__builtins__} is the built-in module
+\module{__builtin__} (note: no `s'); when in any other module,
+\code{__builtins__} is an alias for the dictionary of the
+\module{__builtin__} module itself. \code{__builtins__} can be set
+to a user-created dictionary to create a weak form of restricted
+execution\indexii{restricted}{execution}.
+
+\begin{notice}
+ Users should not touch \code{__builtins__}; it is strictly an
+ implementation detail. Users wanting to override values in the
+ built-in namespace should \keyword{import} the \module{__builtin__}
+ (no `s') module and modify its attributes appropriately.
+\end{notice}
The namespace for a module is automatically created the first time a
module is imported. The main module for a script is always called