else:
parallel_msg = None
- import __builtin__
+ import builtins
- _builtin_file = __builtin__.file
- _builtin_open = __builtin__.open
+ _builtin_file = builtins.file
+ _builtin_open = builtins.open
def _scons_file(*args, **kw):
fp = _builtin_file(*args, **kw)
0)
return fp
- __builtin__.file = _scons_file
- __builtin__.open = _scons_open
+ builtins.file = _scons_file
+ builtins.open = _scons_open
# original builtin functions whenever we have to reset
# all of our global state.
- import __builtin__
+ import builtins
import SCons.Platform.win32
- __builtin__.file = SCons.Platform.win32._builtin_file
- __builtin__.open = SCons.Platform.win32._builtin_open
+ builtins.file = SCons.Platform.win32._builtin_file
+ builtins.open = SCons.Platform.win32._builtin_open
def _baseTryXXX(self, TryFunc):
# TryCompile and TryLink are much the same, so we can test them
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import SCons.compat
+
import copy
import os
import os.path
# OSError subclass on Windows.)
class WindowsError(OSError):
pass
- import __builtin__
- __builtin__.WindowsError = WindowsError
+ import builtins
+ builtins.WindowsError = WindowsError
else:
del e
Other code will not generally reference things in this package through
the SCons.compat namespace. The modules included here add things to
-the __builtin__ namespace or the global module list so that the rest
+the builtins namespace or the global module list so that the rest
of our code can use the objects and names imported here regardless of
Python version.
-Simply enough, things that go in the __builtin__ name space come from
-our builtins module.
+Simply enough, things that go in the builtins name space come from
+our _scons_builtins module.
The rest of the things here will be in individual compatibility modules
that are either: 1) suitably modified copies of the future modules that
file, filename, suffix_mode_type = imp.find_module(module, [dir])
imp.load_module(name, file, filename, suffix_mode_type)
+
+try:
+ import builtins
+except ImportError:
+ # Use the "imp" module to protect the import from fixers.
+ import imp
+ import sys
+ __builtin__ = imp.load_module('__builtin__',
+ *imp.find_module('__builtin__'))
+ sys.modules['builtins'] = __builtin__
+ del __builtin__
+
import _scons_builtins
+
try:
import hashlib
except ImportError:
except NameError:
# Pre-2.4 Python has no native set type
import_as('_scons_sets', 'sets')
- import __builtin__, sets
- __builtin__.set = sets.Set
+ import builtins, sets
+ builtins.set = sets.Set
try:
sys.intern
except AttributeError:
# Pre-2.6 Python has no sys.intern() function.
- import __builtin__
+ import builtins
try:
- sys.intern = __builtin__.intern
+ sys.intern = builtins.intern
except AttributeError:
# Pre-2.x Python has no builtin intern() function.
def intern(x):
tempfile.mkstemp = mkstemp
del mkstemp
-try:
- # pre-2.7 doesn't have the memoryview() built-in
- memoryview
-except NameError:
- class memoryview:
- from types import SliceType
- def __init__(self, obj):
- # wrapping buffer in () keeps the fixer from changing it
- self.obj = (buffer)(obj)
- def __getitem__(self, indx):
- if isinstance(indx, self.SliceType):
- return self.obj[indx.start:indx.stop]
- else:
- return self.obj[indx]
- import __builtin__
- __builtin__.memoryview = memoryview
-
# Local Variables:
# tab-width:4
# Copyright (c) 2001-2004 Twisted Matrix Laboratories
__doc__ = """
-Compatibility idioms for __builtin__ names
+Compatibility idioms for builtins names
-This module adds names to the __builtin__ module for things that we want
+This module adds names to the builtins module for things that we want
to use in SCons but which don't show up until later Python versions than
the earliest ones we support.
-This module checks for the following __builtin__ names:
+This module checks for the following builtins names:
all()
any()
bool()
dict()
sorted()
+ memoryview()
True
False
zip()
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import __builtin__
+import builtins
try:
all
if not element:
return False
return True
- __builtin__.all = all
+ builtins.all = all
all = all
try:
if element:
return True
return False
- __builtin__.any = any
+ builtins.any = any
any = any
try:
worth the trouble.
"""
return not not value
- __builtin__.bool = bool
+ builtins.bool = bool
bool = bool
try:
d[k] = v
d.update(kwargs)
return d
- __builtin__.dict = dict
+ builtins.dict = dict
try:
False
except NameError:
# Pre-2.2 Python has no False keyword.
- __builtin__.False = not 1
+ builtins.False = not 1
# Assign to False in this module namespace so it shows up in pydoc output.
False = False
True
except NameError:
# Pre-2.2 Python has no True keyword.
- __builtin__.True = not 0
+ builtins.True = not 0
# Assign to True in this module namespace so it shows up in pydoc output.
True = True
file
except NameError:
# Pre-2.2 Python has no file() function.
- __builtin__.file = open
+ builtins.file = open
+
+try:
+ memoryview
+except NameError:
+ # Pre-2.7 doesn't have the memoryview() built-in.
+ class memoryview:
+ from types import SliceType
+ def __init__(self, obj):
+ # wrapping buffer in () keeps the fixer from changing it
+ self.obj = (buffer)(obj)
+ def __getitem__(self, indx):
+ if isinstance(indx, self.SliceType):
+ return self.obj[indx.start:indx.stop]
+ else:
+ return self.obj[indx]
+ builtins.memoryview = memoryview
try:
sorted
if reverse:
result.reverse()
return result
- __builtin__.sorted = sorted
+ builtins.sorted = sorted
#
try:
for i in range(min(list(map(len, lists)))):
result.append(tuple([l[i] for l in lists]))
return result
- __builtin__.zip = zip
+ builtins.zip = zip
#if sys.version_info[:3] in ((2, 2, 0), (2, 2, 1)):
# def lstrip(s, c=string.whitespace):
self.type = "string"
else:
# Allow type objects or builtin type conversion functions
- # (int, str, etc.) as an alternative to their names. (The
- # complicated check of __builtin__ is only necessary for
- # Python 2.1 and earlier, and is short-circuited by the
- # first check on modern Pythons.)
- import __builtin__
- if ( isinstance(self.type, type) or
- (hasattr(self.type, "__name__") and
- getattr(__builtin__, self.type.__name__, None) is self.type) ):
+ # (int, str, etc.) as an alternative to their names.
+ if isinstance(self.type, type):
self.type = self.type.__name__
if self.type == "str":
import SCons.compat
+import builtins
import os
# compat layer imports "cPickle" for us if it's available.
import pickle
import shutil
import time
-import __builtin__
keep_all_files = 00000
ignore_corrupt_dbfiles = 0
# See the discussion at:
# http://mail.python.org/pipermail/python-bugs-list/2003-March/016877.html
- _open = __builtin__.open
+ _open = builtins.open
_pickle_dump = pickle.dump
_os_chmod = os.chmod
try: