Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a3284e

Browse files
committed
#1535: rename __builtin__ module to builtins.
1 parent 87f9c53 commit 1a3284e

70 files changed

Lines changed: 246 additions & 247 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Demo/classes/Range.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def __getitem__(self, i):
6464

6565

6666
def test():
67-
import time, __builtin__
67+
import time, builtins
6868
#Just a quick sanity check
69-
correct_result = __builtin__.range(5, 100, 3)
69+
correct_result = builtins.range(5, 100, 3)
7070
oldrange_result = list(oldrange(5, 100, 3))
7171
genrange_result = list(genrange(5, 100, 3))
7272
if genrange_result != correct_result or oldrange_result != correct_result:
@@ -81,7 +81,7 @@ def test():
8181
for i in genrange(1000):
8282
pass
8383
t3 = time.time()
84-
for i in __builtin__.range(1000):
84+
for i in builtins.range(1000):
8585
pass
8686
t4 = time.time()
8787
print(t2-t1, 'sec (old-style class)')

Demo/imputil/knee.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
"""
99

10-
import sys, imp, __builtin__
10+
import sys, imp, builtins
1111

1212

1313
# Replacement for __import__()
@@ -117,7 +117,7 @@ def reload(module):
117117

118118

119119
# Save the original hooks
120-
original_import = __builtin__.__import__
120+
original_import = builtins.__import__
121121

122122
# Now install our hooks
123-
__builtin__.__import__ = import_hook
123+
builtins.__import__ = import_hook

Demo/pdist/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import socket
55
import pickle
6-
import __builtin__
6+
import builtins
77
import os
88

99

@@ -90,8 +90,8 @@ def _recv(self, id):
9090
if exception is None:
9191
return value
9292
x = exception
93-
if hasattr(__builtin__, exception):
94-
x = getattr(__builtin__, exception)
93+
if hasattr(builtins, exception):
94+
x = getattr(builtins, exception)
9595
elif exception in ('posix.error', 'mac.error'):
9696
x = os.error
9797
if x == exception:

Doc/c-api/init.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Initialization, Finalization, and Threads
1717
single: PyEval_AcquireLock()
1818
single: modules (in module sys)
1919
single: path (in module sys)
20-
module: __builtin__
20+
module: builtins
2121
module: __main__
2222
module: sys
2323
triple: module; search; path
@@ -29,7 +29,7 @@ Initialization, Finalization, and Threads
2929
exception of :cfunc:`Py_SetProgramName`, :cfunc:`PyEval_InitThreads`,
3030
:cfunc:`PyEval_ReleaseLock`, and :cfunc:`PyEval_AcquireLock`. This initializes
3131
the table of loaded modules (``sys.modules``), and creates the fundamental
32-
modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`. It also initializes
32+
modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It also initializes
3333
the module search path (``sys.path``). It does not set ``sys.argv``; use
3434
:cfunc:`PySys_SetArgv` for that. This is a no-op when called for a second time
3535
(without calling :cfunc:`Py_Finalize` first). There is no return value; it is a
@@ -83,7 +83,7 @@ Initialization, Finalization, and Threads
8383
.. cfunction:: PyThreadState* Py_NewInterpreter()
8484

8585
.. index::
86-
module: __builtin__
86+
module: builtins
8787
module: __main__
8888
module: sys
8989
single: stdout (in module sys)
@@ -93,7 +93,7 @@ Initialization, Finalization, and Threads
9393
Create a new sub-interpreter. This is an (almost) totally separate environment
9494
for the execution of Python code. In particular, the new interpreter has
9595
separate, independent versions of all imported modules, including the
96-
fundamental modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`. The
96+
fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. The
9797
table of loaded modules (``sys.modules``) and the module search path
9898
(``sys.path``) are also separate. The new environment has no ``sys.argv``
9999
variable. It has new standard I/O stream file objects ``sys.stdin``,

Doc/c-api/intro.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ interpreter can only be used after the interpreter has been initialized.
507507

508508
.. index::
509509
single: Py_Initialize()
510-
module: __builtin__
510+
module: builtins
511511
module: __main__
512512
module: sys
513513
module: exceptions
@@ -516,7 +516,7 @@ interpreter can only be used after the interpreter has been initialized.
516516

517517
The basic initialization function is :cfunc:`Py_Initialize`. This initializes
518518
the table of loaded modules, and creates the fundamental modules
519-
:mod:`__builtin__`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`. It also
519+
:mod:`builtins`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`. It also
520520
initializes the module search path (``sys.path``).
521521

522522
.. index:: single: PySys_SetArgv()

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ Glossary
268268
dictionaries. There are the local, global and builtin namespaces as well
269269
as nested namespaces in objects (in methods). Namespaces support
270270
modularity by preventing naming conflicts. For instance, the functions
271-
:func:`__builtin__.open` and :func:`os.open` are distinguished by their
271+
:func:`builtins.open` and :func:`os.open` are distinguished by their
272272
namespaces. Namespaces also aid readability and maintainability by making
273273
it clear which module implements a function. For instance, writing
274274
:func:`random.seed` or :func:`itertools.izip` makes it clear that those
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
:mod:`__builtin__` --- Built-in objects
3-
=======================================
2+
:mod:`builtins` --- Built-in objects
3+
====================================
44

5-
.. module:: __builtin__
5+
.. module:: builtins
66
:synopsis: The module that provides the built-in namespace.
77

88

99
This module provides direct access to all 'built-in' identifiers of Python; for
10-
example, ``__builtin__.open`` is the full name for the built-in function
10+
example, ``builtins.open`` is the full name for the built-in function
1111
:func:`open`. See chapter :ref:`builtin`.
1212

1313
This module is not normally accessed explicitly by most applications, but can be
@@ -16,10 +16,10 @@ but in which the built-in of that name is also needed. For example, in a module
1616
that wants to implement an :func:`open` function that wraps the built-in
1717
:func:`open`, this module can be used directly::
1818

19-
import __builtin__
19+
import builtins
2020

2121
def open(path):
22-
f = __builtin__.open(path, 'r')
22+
f = builtins.open(path, 'r')
2323
return UpperCaser(f)
2424

2525
class UpperCaser:

Doc/library/functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ available. They are listed here in alphabetical order.
356356
dictionaries as global and local namespace. If the *globals* dictionary is
357357
present and lacks '__builtins__', the current globals are copied into *globals*
358358
before *expression* is parsed. This means that *expression* normally has full
359-
access to the standard :mod:`__builtin__` module and restricted environments are
359+
access to the standard :mod:`builtins` module and restricted environments are
360360
propagated. If the *locals* dictionary is omitted it defaults to the *globals*
361361
dictionary. If both dictionaries are omitted, the expression is executed in the
362362
environment where :keyword:`eval` is called. The return value is the result of
@@ -398,7 +398,7 @@ available. They are listed here in alphabetical order.
398398

399399
If the *globals* dictionary does not contain a value for the key
400400
``__builtins__``, a reference to the dictionary of the built-in module
401-
:mod:`__builtin__` is inserted under that key. That way you can control what
401+
:mod:`builtins` is inserted under that key. That way you can control what
402402
builtins are available to the executed code by inserting your own
403403
``__builtins__`` dictionary into *globals* before passing it to :func:`exec`.
404404

Doc/library/imputil.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ This code is intended to be read, not executed. However, it does work
108108

109109
::
110110

111-
import sys, imp, __builtin__
111+
import sys, imp, builtins
112112

113113
# Replacement for __import__()
114114
def import_hook(name, globals=None, locals=None, fromlist=None):
@@ -218,12 +218,12 @@ This code is intended to be read, not executed. However, it does work
218218

219219

220220
# Save the original hooks
221-
original_import = __builtin__.__import__
222-
original_reload = __builtin__.reload
221+
original_import = builtins.__import__
222+
original_reload = builtins.reload
223223

224224
# Now install our hooks
225-
__builtin__.__import__ = import_hook
226-
__builtin__.reload = reload_hook
225+
builtins.__import__ = import_hook
226+
builtins.reload = reload_hook
227227

228228
.. index::
229229
module: knee

Doc/library/python.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ overview:
1313
.. toctree::
1414

1515
sys.rst
16-
__builtin__.rst
16+
builtins.rst
1717
__main__.rst
1818
warnings.rst
1919
contextlib.rst

0 commit comments

Comments
 (0)