SCons.compat

Package SCons :: Package compat |
[hide private]
[frames] | no frames]

# Package compat

source code

SCons compatibility package for old Python versions

This subpackage holds modules that provide backwards-compatible implementations of various things that we'd like to use in SCons but which only show up in later versions of Python than the early, old version(s) we still support.

This package will be imported by other code:

> import SCons.compat

But 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 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.

The rest of the things here will be in individual compatibility modules that are either: 1) suitably modified copies of the future modules that we want to use; or 2) backwards compatible re-implementations of the specific portions of a future module's API that we want to use.

GENERAL WARNINGS: Implementations of functions in the SCons.compat modules are NOT guaranteed to be fully compliant with these functions in later versions of Python. We are only concerned with adding functionality that we actually use in SCons, so be wary if you lift this code for other uses. (That said, making these more nearly the same as later, official versions is still a desirable goal, we just don't need to be obsessive about it.)

We name the compatibility modules with an initial '_scons_' (for example, _scons_subprocess.py is our compatibility module for subprocess) so that we can still try to import the real module name and fall back to our compatibility module if we get an ImportError. The import_as() function defined below loads the module as the "real" name (without the '_scons'), after which all of the "import {module}" statements in the rest of our code will find our pre-loaded compatibility module.

Submodules | [hide private]
SCons.compat._scons_UserString: A user-defined wrapper around string objects SCons.compat._scons_hashlib: hashlib backwards-compatibility module for older (pre-2.5) Python versions SCons.compat._scons_optparse: optparse - a powerful, extensible, and easy-to-use option parser. SCons.compat._scons_sets: Classes to represent arbitrary sets (including sets of sets). SCons.compat._scons_sets15 SCons.compat._scons_shlex: A lexical analyzer class for simple shell-like syntaxes. SCons.compat._scons_subprocess: subprocess - Subprocesses with accessible I/O streams This module allows you to spawn processes, connect to their input/output/error pipes, and obtain their return codes. SCons.compat._scons_textwrap: Text wrapping and filling. SCons.compat.builtins: Compatibility idioms for __builtin__ names

Functions | [hide private]
import_as(module, name) Imports the specified module (from our local directory) as the specified name. | source code

Variables | [hide private]
| __doc__ = ``...``
| __revision__ = ``'``src/engine/SCons/compat/__init__.py 2725 2008/``...``
| version_string = `string.split(sys.version) [0]`
| version_ints = `map(int, string.split(version_string, '.'))`

Variables Details | [hide private]

  ### __doc__ Value:
      """
      SCons compatibility package for old Python versions

      This subpackage holds modules that provide backwards-compatible
      implementations of various things that we'd like to use in SCons but w
      hich
      only show up in later versions of Python than the early, old version(s
      )
      ...

  ### __revision__ Value:
      'src/engine/SCons/compat/__init__.py 2725 2008/03/31 12:52:02 knight'