File indexing completed on 2024-04-28 15:53:59
0001 #!/usr/bin/env python2.7 0002 # -*- coding: utf-8 -*- 0003 """:synopsis: Access system-specific parameters and functions. 0004 0005 0006 This module provides access to some variables used or maintained by the 0007 interpreter and to functions that interact strongly with the interpreter. It is 0008 always available. 0009 0010 0011 """ 0012 """ 0013 The list of command line arguments passed to a Python script. ``argv[0]`` is the 0014 script name (it is operating system dependent whether this is a full pathname or 0015 not). If the command was executed using the :option:`-c` command line option to 0016 the interpreter, ``argv[0]`` is set to the string ``'-c'``. If no script name 0017 was passed to the Python interpreter, ``argv[0]`` is the empty string. 0018 0019 To loop over the standard input, or the list of files given on the 0020 command line, see the :mod:`fileinput` module. 0021 0022 0023 """ 0024 argv = [str()] 0025 """ 0026 An indicator of the native byte order. This will have the value ``'big'`` on 0027 big-endian (most-significant byte first) platforms, and ``'little'`` on 0028 little-endian (least-significant byte first) platforms. 0029 0030 """ 0031 byteorder = str() 0032 """ 0033 A triple (repo, branch, version) representing the Subversion information of the 0034 Python interpreter. *repo* is the name of the repository, ``'CPython'``. 0035 *branch* is a string of one of the forms ``'trunk'``, ``'branches/name'`` or 0036 ``'tags/name'``. *version* is the output of ``svnversion``, if the interpreter 0037 was built from a Subversion checkout; it contains the revision number (range) 0038 and possibly a trailing 'M' if there were local modifications. If the tree was 0039 exported (or svnversion was not available), it is the revision of 0040 ``Include/patchlevel.h`` if the branch is a tag. Otherwise, it is ``None``. 0041 0042 """ 0043 subversion = (str(), str(), str()) 0044 """ 0045 A tuple of strings giving the names of all modules that are compiled into this 0046 Python interpreter. (This information is not available in any other way --- 0047 ``modules.keys()`` only lists the imported modules.) 0048 0049 0050 """ 0051 builtin_module_names = (str()) 0052 """ 0053 A string containing the copyright pertaining to the Python interpreter. 0054 0055 0056 """ 0057 copyright = str() 0058 """ 0059 Integer specifying the handle of the Python DLL. Availability: Windows. 0060 0061 0062 """ 0063 dllhandle = int() 0064 """__excepthook__ 0065 0066 These objects contain the original values of ``displayhook`` and ``excepthook`` 0067 at the start of the program. They are saved so that ``displayhook`` and 0068 ``excepthook`` can be restored in case they happen to get replaced with broken 0069 objects. 0070 0071 0072 """ 0073 __displayhook__ = None 0074 exc_value = None 0075 exc_traceback = None 0076 exc_type = None 0077 """ 0078 A string giving the site-specific directory prefix where the platform-dependent 0079 Python files are installed; by default, this is also ``'/usr/local'``. This can 0080 be set at build time with the ``--exec-prefix`` argument to the 0081 :program:`configure` script. Specifically, all configuration files (e.g. the 0082 :file:`pyconfig.h` header file) are installed in the directory ``exec_prefix + 0083 '/lib/pythonversion/config'``, and shared library modules are installed in 0084 ``exec_prefix + '/lib/pythonversion/lib-dynload'``, where *version* is equal to 0085 ``version[:3]``. 0086 0087 0088 """ 0089 exec_prefix = str() 0090 """ 0091 A string giving the name of the executable binary for the Python interpreter, on 0092 systems where this makes sense. 0093 0094 0095 """ 0096 executable = str() 0097 """ 0098 This value is not actually defined by the module, but can be set by the user (or 0099 by a program) to specify a clean-up action at program exit. When set, it should 0100 be a parameterless function. This function will be called when the interpreter 0101 exits. Only one function may be installed in this way; to allow multiple 0102 functions which will be called at termination, use the :mod:`atexit` module. 0103 0104 """ 0105 exitfunc = lambda: None 0106 """ 0107 The struct sequence *flags* exposes the status of command line flags. The 0108 attributes are read only. 0109 0110 ============================= =================================== 0111 attribute flag 0112 ============================= =================================== 0113 :const:`debug` :option:`-d` 0114 :const:`py3k_warning` :option:`-3` 0115 :const:`division_warning` :option:`-Q` 0116 :const:`division_new` :option:`-Qnew <-Q>` 0117 :const:`inspect` :option:`-i` 0118 :const:`interactive` :option:`-i` 0119 :const:`optimize` :option:`-O` or :option:`-OO` 0120 :const:`dont_write_bytecode` :option:`-B` 0121 :const:`no_user_site` :option:`-s` 0122 :const:`no_site` :option:`-S` 0123 :const:`ignore_environment` :option:`-E` 0124 :const:`tabcheck` :option:`-t` or :option:`-tt <-t>` 0125 :const:`verbose` :option:`-v` 0126 :const:`unicode` :option:`-U` 0127 :const:`bytes_warning` :option:`-b` 0128 ============================= =================================== 0129 0130 """ 0131 flags = None 0132 """ 0133 A structseq holding information about the float type. It contains low level 0134 information about the precision and internal representation. The values 0135 correspond to the various floating-point constants defined in the standard 0136 header file :file:`float.h` for the 'C' programming language; see section 0137 5.2.4.2.2 of the 1999 ISO/IEC C standard [C99]_, 'Characteristics of 0138 floating types', for details. 0139 0140 +---------------------+----------------+--------------------------------------------------+ 0141 | attribute | float.h macro | explanation | 0142 +=====================+================+==================================================+ 0143 | :const:`epsilon` | DBL_EPSILON | difference between 1 and the least value greater | 0144 | | | than 1 that is representable as a float | 0145 +---------------------+----------------+--------------------------------------------------+ 0146 | :const:`dig` | DBL_DIG | maximum number of decimal digits that can be | 0147 | | | faithfully represented in a float; see below | 0148 +---------------------+----------------+--------------------------------------------------+ 0149 | :const:`mant_dig` | DBL_MANT_DIG | float precision: the number of base-``radix`` | 0150 | | | digits in the significand of a float | 0151 +---------------------+----------------+--------------------------------------------------+ 0152 | :const:`max` | DBL_MAX | maximum representable finite float | 0153 +---------------------+----------------+--------------------------------------------------+ 0154 | :const:`max_exp` | DBL_MAX_EXP | maximum integer e such that ``radix**(e-1)`` is | 0155 | | | a representable finite float | 0156 +---------------------+----------------+--------------------------------------------------+ 0157 | :const:`max_10_exp` | DBL_MAX_10_EXP | maximum integer e such that ``10**e`` is in the | 0158 | | | range of representable finite floats | 0159 +---------------------+----------------+--------------------------------------------------+ 0160 | :const:`min` | DBL_MIN | minimum positive normalized float | 0161 +---------------------+----------------+--------------------------------------------------+ 0162 | :const:`min_exp` | DBL_MIN_EXP | minimum integer e such that ``radix**(e-1)`` is | 0163 | | | a normalized float | 0164 +---------------------+----------------+--------------------------------------------------+ 0165 | :const:`min_10_exp` | DBL_MIN_10_EXP | minimum integer e such that ``10**e`` is a | 0166 | | | normalized float | 0167 +---------------------+----------------+--------------------------------------------------+ 0168 | :const:`radix` | FLT_RADIX | radix of exponent representation | 0169 +---------------------+----------------+--------------------------------------------------+ 0170 | :const:`rounds` | FLT_ROUNDS | constant representing rounding mode | 0171 | | | used for arithmetic operations | 0172 +---------------------+----------------+--------------------------------------------------+ 0173 0174 The attribute :attr:`sys.float_info.dig` needs further explanation. If 0175 ``s`` is any string representing a decimal number with at most 0176 :attr:`sys.float_info.dig` significant digits, then converting ``s`` to a 0177 float and back again will recover a string representing the same decimal 0178 value:: 0179 0180 >>> import sys 0181 >>> sys.float_info.dig 0182 15 0183 >>> s = '3.14159265358979' # decimal string with 15 significant digits 0184 >>> format(float(s), '.15g') # convert to float and back -> same value 0185 '3.14159265358979' 0186 0187 But for strings with more than :attr:`sys.float_info.dig` significant digits, 0188 this isn't always true:: 0189 0190 >>> s = '9876543211234567' # 16 significant digits is too many! 0191 >>> format(float(s), '.16g') # conversion changes value 0192 '9876543211234568' 0193 0194 """ 0195 float_info = None 0196 """ 0197 A string indicating how the :func:`repr` function behaves for 0198 floats. If the string has value ``'short'`` then for a finite 0199 float ``x``, ``repr(x)`` aims to produce a short string with the 0200 property that ``float(repr(x)) == x``. This is the usual behaviour 0201 in Python 2.7 and later. Otherwise, ``float_repr_style`` has value 0202 ``'legacy'`` and ``repr(x)`` behaves in the same way as it did in 0203 versions of Python prior to 2.7. 0204 0205 """ 0206 float_repr_style = str() 0207 """ 0208 The version number encoded as a single integer. This is guaranteed to increase 0209 with each version, including proper support for non-production releases. For 0210 example, to test that the Python interpreter is at least version 1.5.2, use:: 0211 0212 if sys.hexversion >= 0x010502F0: 0213 # use some advanced feature 0214 more 0215 else: 0216 # use an alternative implementation or warn the user 0217 more 0218 0219 This is called ``hexversion`` since it only really looks meaningful when viewed 0220 as the result of passing it to the built-in :func:`hex` function. The 0221 ``version_info`` value may be used for a more human-friendly encoding of the 0222 same information. 0223 0224 The ``hexversion`` is a 32-bit number with the following layout: 0225 0226 +-------------------------+------------------------------------------------+ 0227 | Bits (big endian order) | Meaning | 0228 +=========================+================================================+ 0229 | :const:`1-8` | ``PY_MAJOR_VERSION`` (the ``2`` in | 0230 | | ``2.1.0a3``) | 0231 +-------------------------+------------------------------------------------+ 0232 | :const:`9-16` | ``PY_MINOR_VERSION`` (the ``1`` in | 0233 | | ``2.1.0a3``) | 0234 +-------------------------+------------------------------------------------+ 0235 | :const:`17-24` | ``PY_MICRO_VERSION`` (the ``0`` in | 0236 | | ``2.1.0a3``) | 0237 +-------------------------+------------------------------------------------+ 0238 | :const:`25-28` | ``PY_RELEASE_LEVEL`` (``0xA`` for alpha, | 0239 | | ``0xB`` for beta, ``0xC`` for release | 0240 | | candidate and ``0xF`` for final) | 0241 +-------------------------+------------------------------------------------+ 0242 | :const:`29-32` | ``PY_RELEASE_SERIAL`` (the ``3`` in | 0243 | | ``2.1.0a3``, zero for final releases) | 0244 +-------------------------+------------------------------------------------+ 0245 0246 Thus ``2.1.0a3`` is hexversion ``0x020100a3``. 0247 0248 """ 0249 hexversion = str() 0250 """ 0251 A struct sequence that holds information about Python's 0252 internal representation of integers. The attributes are read only. 0253 0254 +-------------------------+----------------------------------------------+ 0255 | Attribute | Explanation | 0256 +=========================+==============================================+ 0257 | :const:`bits_per_digit` | number of bits held in each digit. Python | 0258 | | integers are stored internally in base | 0259 | | ``2**long_info.bits_per_digit`` | 0260 +-------------------------+----------------------------------------------+ 0261 | :const:`sizeof_digit` | size in bytes of the C type used to | 0262 | | represent a digit | 0263 +-------------------------+----------------------------------------------+ 0264 0265 """ 0266 long_info = None 0267 """ 0268 These three variables are not always defined; they are set when an exception is 0269 not handled and the interpreter prints an error message and a stack traceback. 0270 Their intended use is to allow an interactive user to import a debugger module 0271 and engage in post-mortem debugging without having to re-execute the command 0272 that caused the error. (Typical use is ``import pdb; pdb.pm()`` to enter the 0273 post-mortem debugger; see chapter :ref:`debugger` for 0274 more information.) 0275 0276 The meaning of the variables is the same as that of the return values from 0277 :func:`exc_info` above. (Since there is only one interactive thread, 0278 thread-safety is not a concern for these variables, unlike for ``exc_type`` 0279 etc.) 0280 0281 0282 """ 0283 last_traceback = None 0284 last_value = None 0285 last_type = None 0286 """ 0287 The largest positive integer supported by Python's regular integer type. This 0288 is at least 2\*\*31-1. The largest negative integer is ``-maxint-1`` --- the 0289 asymmetry results from the use of 2's complement binary arithmetic. 0290 0291 """ 0292 maxint = int() 0293 """ 0294 The largest positive integer supported by the platform's Py_ssize_t type, 0295 and thus the maximum size lists, strings, dicts, and many other containers 0296 can have. 0297 0298 """ 0299 maxsize = int() 0300 """ 0301 An integer giving the largest supported code point for a Unicode character. The 0302 value of this depends on the configuration option that specifies whether Unicode 0303 characters are stored as UCS-2 or UCS-4. 0304 0305 0306 """ 0307 maxunicode = int() 0308 """ 0309 A list of :term:`finder` objects that have their :meth:`find_module` 0310 methods called to see if one of the objects can find the module to be 0311 imported. The :meth:`find_module` method is called at least with the 0312 absolute name of the module being imported. If the module to be imported is 0313 contained in package then the parent package's :attr:`__path__` attribute 0314 is passed in as a second argument. The method returns :keyword:`None` if 0315 the module cannot be found, else returns a :term:`loader`. 0316 0317 :data:`sys.meta_path` is searched before any implicit default finders or 0318 :data:`sys.path`. 0319 0320 See :pep:`302` for the original specification. 0321 0322 0323 """ 0324 meta_path = [None] 0325 modules = None 0326 path = [str()] 0327 """ 0328 A list of callables that take a path argument to try to create a 0329 :term:`finder` for the path. If a finder can be created, it is to be 0330 returned by the callable, else raise :exc:`ImportError`. 0331 0332 Originally specified in :pep:`302`. 0333 0334 0335 """ 0336 path_hooks = [lambda: None] 0337 """ 0338 A dictionary acting as a cache for :term:`finder` objects. The keys are 0339 paths that have been passed to :data:`sys.path_hooks` and the values are 0340 the finders that are found. If a path is a valid file system path but no 0341 explicit finder is found on :data:`sys.path_hooks` then :keyword:`None` is 0342 stored to represent the implicit default finder should be used. If the path 0343 is not an existing path then :class:`imp.NullImporter` is set. 0344 0345 Originally specified in :pep:`302`. 0346 0347 0348 """ 0349 path_importer_cache = None 0350 """ 0351 This string contains a platform identifier that can be used to append 0352 platform-specific components to :data:`sys.path`, for instance. 0353 0354 For Unix systems, this is the lowercased OS name as returned by ``uname -s`` 0355 with the first part of the version as returned by ``uname -r`` appended, 0356 e.g. ``'sunos5'`` or ``'linux2'``, *at the time when Python was built*. 0357 For other systems, the values are: 0358 0359 ================ =========================== 0360 System :data:`platform` value 0361 ================ =========================== 0362 Windows ``'win32'`` 0363 Windows/Cygwin ``'cygwin'`` 0364 Mac OS X ``'darwin'`` 0365 OS/2 ``'os2'`` 0366 OS/2 EMX ``'os2emx'`` 0367 RiscOS ``'riscos'`` 0368 AtheOS ``'atheos'`` 0369 ================ =========================== 0370 0371 0372 """ 0373 platform = str() 0374 """ 0375 A string giving the site-specific directory prefix where the platform 0376 independent Python files are installed; by default, this is the string 0377 ``'/usr/local'``. This can be set at build time with the ``--prefix`` 0378 argument to the :program:`configure` script. The main collection of Python 0379 library modules is installed in the directory ``prefix + '/lib/pythonversion'`` 0380 while the platform independent header files (all except :file:`pyconfig.h`) are 0381 stored in ``prefix + '/include/pythonversion'``, where *version* is equal to 0382 ``version[:3]``. 0383 0384 0385 """ 0386 prefix = str() 0387 ps2 = None 0388 ps1 = None 0389 """ 0390 Bool containing the status of the Python 3.0 warning flag. It's ``True`` 0391 when Python is started with the -3 option. (This should be considered 0392 read-only; setting it to a different value doesn't have an effect on 0393 Python 3.0 warnings.) 0394 0395 """ 0396 py3kwarning = False 0397 """ 0398 If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the 0399 import of source modules. This value is initially set to ``True`` or ``False`` 0400 depending on the ``-B`` command line option and the ``PYTHONDONTWRITEBYTECODE`` 0401 environment variable, but you can set it yourself to control bytecode file 0402 generation. 0403 0404 """ 0405 dont_write_bytecode = False 0406 """ 0407 File objects corresponding to the interpreter's standard input, output and error 0408 streams. ``stdin`` is used for all interpreter input except for scripts but 0409 including calls to :func:`input` and :func:`raw_input`. ``stdout`` is used for 0410 the output of :keyword:`print` and :term:`expression` statements and for the 0411 prompts of :func:`input` and :func:`raw_input`. The interpreter's own prompts 0412 and (almost all of) its error messages go to ``stderr``. ``stdout`` and 0413 ``stderr`` needn't be built-in file objects: any object is acceptable as long 0414 as it has a :meth:`write` method that takes a string argument. (Changing these 0415 objects doesn't affect the standard I/O streams of processes executed by 0416 :func:`os.popen`, :func:`os.system` or the :func:`exec\*` family of functions in 0417 the :mod:`os` module.) 0418 0419 0420 """ 0421 stdin = open("stdin", "rw") 0422 """ 0423 File objects corresponding to the interpreter's standard input, output and error 0424 streams. ``stdin`` is used for all interpreter input except for scripts but 0425 including calls to :func:`input` and :func:`raw_input`. ``stdout`` is used for 0426 the output of :keyword:`print` and :term:`expression` statements and for the 0427 prompts of :func:`input` and :func:`raw_input`. The interpreter's own prompts 0428 and (almost all of) its error messages go to ``stderr``. ``stdout`` and 0429 ``stderr`` needn't be built-in file objects: any object is acceptable as long 0430 as it has a :meth:`write` method that takes a string argument. (Changing these 0431 objects doesn't affect the standard I/O streams of processes executed by 0432 :func:`os.popen`, :func:`os.system` or the :func:`exec\*` family of functions in 0433 the :mod:`os` module.) 0434 0435 0436 """ 0437 stdout = open("stdout", "rw") 0438 """ 0439 File objects corresponding to the interpreter's standard input, output and error 0440 streams. ``stdin`` is used for all interpreter input except for scripts but 0441 including calls to :func:`input` and :func:`raw_input`. ``stdout`` is used for 0442 the output of :keyword:`print` and :term:`expression` statements and for the 0443 prompts of :func:`input` and :func:`raw_input`. The interpreter's own prompts 0444 and (almost all of) its error messages go to ``stderr``. ``stdout`` and 0445 ``stderr`` needn't be built-in file objects: any object is acceptable as long 0446 as it has a :meth:`write` method that takes a string argument. (Changing these 0447 objects doesn't affect the standard I/O streams of processes executed by 0448 :func:`os.popen`, :func:`os.system` or the :func:`exec\*` family of functions in 0449 the :mod:`os` module.) 0450 0451 0452 """ 0453 stderr = open("stderr", "rw") 0454 """ 0455 These objects contain the original values of ``stdin``, ``stderr`` and 0456 ``stdout`` at the start of the program. They are used during finalization, 0457 and could be useful to print to the actual standard stream no matter if the 0458 ``sys.std*`` object has been redirected. 0459 0460 It can also be used to restore the actual files to known working file objects 0461 in case they have been overwritten with a broken object. However, the 0462 preferred way to do this is to explicitly save the previous stream before 0463 replacing it, and restore the saved object. 0464 0465 0466 """ 0467 __stdout__ = stdout 0468 __stderr__ = stderr 0469 __stdin__ = stdin 0470 """ 0471 When this variable is set to an integer value, it determines the maximum number 0472 of levels of traceback information printed when an unhandled exception occurs. 0473 The default is ``1000``. When set to ``0`` or less, all traceback information 0474 is suppressed and only the exception type and value are printed. 0475 0476 0477 """ 0478 tracebacklimit = 1000 0479 """ 0480 A string containing the version number of the Python interpreter plus additional 0481 information on the build number and compiler used. This string is displayed 0482 when the interactive interpreter is started. Do not extract version information 0483 out of it, rather, use :data:`version_info` and the functions provided by the 0484 :mod:`platform` module. 0485 0486 0487 """ 0488 version = str() 0489 """ 0490 The C API version for this interpreter. Programmers may find this useful when 0491 debugging version conflicts between Python and extension modules. 0492 0493 """ 0494 api_version = str() 0495 """ 0496 A tuple containing the five components of the version number: *major*, *minor*, 0497 *micro*, *releaselevel*, and *serial*. All values except *releaselevel* are 0498 integers; the release level is ``'alpha'``, ``'beta'``, ``'candidate'``, or 0499 ``'final'``. The ``version_info`` value corresponding to the Python version 2.0 0500 is ``(2, 0, 0, 'final', 0)``. The components can also be accessed by name, 0501 so ``sys.version_info[0]`` is equivalent to ``sys.version_info.major`` 0502 and so on. 0503 0504 """ 0505 version_info = (3, 5, 0, 0, 0) 0506 """ 0507 This is an implementation detail of the warnings framework; do not modify this 0508 value. Refer to the :mod:`warnings` module for more information on the warnings 0509 framework. 0510 0511 0512 """ 0513 warnoptions = None 0514 """ 0515 The version number used to form registry keys on Windows platforms. This is 0516 stored as string resource 1000 in the Python DLL. The value is normally the 0517 first three characters of :const:`version`. It is provided in the :mod:`sys` 0518 module for informational purposes; modifying this value has no effect on the 0519 registry keys used by Python. Availability: Windows. 0520 0521 """ 0522 winver = str() 0523 def call_tracing(func,args): 0524 """ 0525 Call ``func(*args)``, while tracing is enabled. The tracing state is saved, 0526 and restored afterwards. This is intended to be called from a debugger from 0527 a checkpoint, to recursively debug some other code. 0528 0529 0530 """ 0531 pass 0532 0533 def _clear_type_cache(): 0534 """ 0535 Clear the internal type cache. The type cache is used to speed up attribute 0536 and method lookups. Use the function *only* to drop unnecessary references 0537 during reference leak debugging. 0538 0539 This function should be used for internal and specialized purposes only. 0540 0541 """ 0542 pass 0543 0544 def _current_frames(): 0545 """ 0546 Return a dictionary mapping each thread's identifier to the topmost stack frame 0547 currently active in that thread at the time the function is called. Note that 0548 functions in the :mod:`traceback` module can build the call stack given such a 0549 frame. 0550 0551 This is most useful for debugging deadlock: this function does not require the 0552 deadlocked threads' cooperation, and such threads' call stacks are frozen for as 0553 long as they remain deadlocked. The frame returned for a non-deadlocked thread 0554 may bear no relationship to that thread's current activity by the time calling 0555 code examines the frame. 0556 0557 This function should be used for internal and specialized purposes only. 0558 0559 """ 0560 dict() 0561 0562 def displayhook(value): 0563 """ 0564 If *value* is not ``None``, this function prints it to ``sys.stdout``, and saves 0565 it in ``__builtin__._``. 0566 0567 ``sys.displayhook`` is called on the result of evaluating an :term:`expression` 0568 entered in an interactive Python session. The display of these values can be 0569 customized by assigning another one-argument function to ``sys.displayhook``. 0570 0571 0572 """ 0573 pass 0574 0575 def excepthook(type,value,traceback): 0576 """ 0577 This function prints out a given traceback and exception to ``sys.stderr``. 0578 0579 When an exception is raised and uncaught, the interpreter calls 0580 ``sys.excepthook`` with three arguments, the exception class, exception 0581 instance, and a traceback object. In an interactive session this happens just 0582 before control is returned to the prompt; in a Python program this happens just 0583 before the program exits. The handling of such top-level exceptions can be 0584 customized by assigning another three-argument function to ``sys.excepthook``. 0585 0586 0587 """ 0588 pass 0589 0590 def exc_info(): 0591 """ 0592 This function returns a tuple of three values that give information about the 0593 exception that is currently being handled. The information returned is specific 0594 both to the current thread and to the current stack frame. If the current stack 0595 frame is not handling an exception, the information is taken from the calling 0596 stack frame, or its caller, and so on until a stack frame is found that is 0597 handling an exception. Here, "handling an exception" is defined as "executing 0598 or having executed an except clause." For any stack frame, only information 0599 about the most recently handled exception is accessible. 0600 0601 """ 0602 return tuple() 0603 0604 def exc_clear(): 0605 """ 0606 This function clears all information relating to the current or last exception 0607 that occurred in the current thread. After calling this function, 0608 :func:`exc_info` will return three ``None`` values until another exception is 0609 raised in the current thread or the execution stack returns to a frame where 0610 another exception is being handled. 0611 0612 This function is only needed in only a few obscure situations. These include 0613 logging and error handling systems that report information on the last or 0614 current exception. This function can also be used to try to free resources and 0615 trigger object finalization, though no guarantee is made as to what objects will 0616 be freed, if any. 0617 0618 """ 0619 pass 0620 0621 def exit(arg: int): 0622 """ 0623 Exit from Python. This is implemented by raising the :exc:`SystemExit` 0624 exception, so cleanup actions specified by finally clauses of :keyword:`try` 0625 statements are honored, and it is possible to intercept the exit attempt at 0626 an outer level. 0627 0628 The optional argument *arg* can be an integer giving the exit status 0629 (defaulting to zero), or another type of object. If it is an integer, zero 0630 is considered "successful termination" and any nonzero value is considered 0631 "abnormal termination" by shells and the like. Most systems require it to be 0632 in the range 0-127, and produce undefined results otherwise. Some systems 0633 have a convention for assigning specific meanings to specific exit codes, but 0634 these are generally underdeveloped; Unix programs generally use 2 for command 0635 line syntax errors and 1 for all other kind of errors. If another type of 0636 object is passed, ``None`` is equivalent to passing zero, and any other 0637 object is printed to :data:`stderr` and results in an exit code of 1. In 0638 particular, ``sys.exit("some error message")`` is a quick way to exit a 0639 program when an error occurs. 0640 0641 Since :func:`exit` ultimately "only" raises an exception, it will only exit 0642 the process when called from the main thread, and the exception is not 0643 intercepted. 0644 0645 0646 """ 0647 pass 0648 0649 def getcheckinterval(): 0650 """ 0651 Return the interpreter's "check interval"; see :func:`setcheckinterval`. 0652 0653 """ 0654 return int() 0655 0656 def getdefaultencoding(): 0657 """ 0658 Return the name of the current default string encoding used by the Unicode 0659 implementation. 0660 0661 """ 0662 return str() 0663 0664 def getdlopenflags(): 0665 """ 0666 Return the current value of the flags that are used for :cfunc:`dlopen` calls. 0667 The flag constants are defined in the :mod:`dl` and :mod:`DLFCN` modules. 0668 Availability: Unix. 0669 0670 """ 0671 return str() 0672 0673 def getfilesystemencoding(): 0674 """ 0675 Return the name of the encoding used to convert Unicode filenames into system 0676 file names, or ``None`` if the system default encoding is used. The result value 0677 depends on the operating system: 0678 0679 * On Mac OS X, the encoding is ``'utf-8'``. 0680 0681 * On Unix, the encoding is the user's preference according to the result of 0682 nl_langinfo(CODESET), or ``None`` if the ``nl_langinfo(CODESET)`` 0683 failed. 0684 0685 * On Windows NT+, file names are Unicode natively, so no conversion is 0686 performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as 0687 this is the encoding that applications should use when they explicitly 0688 want to convert Unicode strings to byte strings that are equivalent when 0689 used as file names. 0690 0691 * On Windows 9x, the encoding is ``'mbcs'``. 0692 0693 """ 0694 return "utf-8" 0695 0696 def getrefcount(object): 0697 """ 0698 Return the reference count of the *object*. The count returned is generally one 0699 higher than you might expect, because it includes the (temporary) reference as 0700 an argument to :func:`getrefcount`. 0701 0702 0703 """ 0704 return 0 0705 0706 def getrecursionlimit(): 0707 """ 0708 Return the current value of the recursion limit, the maximum depth of the Python 0709 interpreter stack. This limit prevents infinite recursion from causing an 0710 overflow of the C stack and crashing Python. It can be set by 0711 :func:`setrecursionlimit`. 0712 0713 0714 """ 0715 return 1000 0716 0717 def getsizeof(object,default): 0718 """ 0719 Return the size of an object in bytes. The object can be any type of 0720 object. All built-in objects will return correct results, but this 0721 does not have to hold true for third-party extensions as it is implementation 0722 specific. 0723 0724 If given, *default* will be returned if the object does not provide means to 0725 retrieve the size. Otherwise a :exc:`TypeError` will be raised. 0726 0727 :func:`getsizeof` calls the object's ``__sizeof__`` method and adds an 0728 additional garbage collector overhead if the object is managed by the garbage 0729 collector. 0730 0731 """ 0732 return 0 0733 0734 def _getframe(depth: int): 0735 """ 0736 Return a frame object from the call stack. If optional integer *depth* is 0737 given, return the frame object that many calls below the top of the stack. If 0738 that is deeper than the call stack, :exc:`ValueError` is raised. The default 0739 for *depth* is zero, returning the frame at the top of the call stack. 0740 0741 """ 0742 pass 0743 0744 def getprofile(): 0745 pass 0746 0747 def gettrace(): 0748 pass 0749 0750 def getwindowsversion(): 0751 """ 0752 Return a named tuple describing the Windows version 0753 currently running. The named elements are *major*, *minor*, 0754 *build*, *platform*, *service_pack*, *service_pack_minor*, 0755 *service_pack_major*, *suite_mask*, and *product_type*. 0756 *service_pack* contains a string while all other values are 0757 integers. The components can also be accessed by name, so 0758 ``sys.getwindowsversion()[0]`` is equivalent to 0759 ``sys.getwindowsversion().major``. For compatibility with prior 0760 versions, only the first 5 elements are retrievable by indexing. 0761 0762 *platform* may be one of the following values: 0763 0764 +-----------------------------------------+-------------------------+ 0765 | Constant | Platform | 0766 +=========================================+=========================+ 0767 | :const:`0 (VER_PLATFORM_WIN32s)` | Win32s on Windows 3.1 | 0768 +-----------------------------------------+-------------------------+ 0769 | :const:`1 (VER_PLATFORM_WIN32_WINDOWS)` | Windows 95/98/ME | 0770 +-----------------------------------------+-------------------------+ 0771 | :const:`2 (VER_PLATFORM_WIN32_NT)` | Windows NT/2000/XP/x64 | 0772 +-----------------------------------------+-------------------------+ 0773 | :const:`3 (VER_PLATFORM_WIN32_CE)` | Windows CE | 0774 +-----------------------------------------+-------------------------+ 0775 0776 *product_type* may be one of the following values: 0777 0778 +---------------------------------------+---------------------------------+ 0779 | Constant | Meaning | 0780 +=======================================+=================================+ 0781 | :const:`1 (VER_NT_WORKSTATION)` | The system is a workstation. | 0782 +---------------------------------------+---------------------------------+ 0783 | :const:`2 (VER_NT_DOMAIN_CONTROLLER)` | The system is a domain | 0784 | | controller. | 0785 +---------------------------------------+---------------------------------+ 0786 | :const:`3 (VER_NT_SERVER)` | The system is a server, but not | 0787 | | a domain controller. | 0788 +---------------------------------------+---------------------------------+ 0789 0790 0791 This function wraps the Win32 :cfunc:`GetVersionEx` function; see the 0792 Microsoft documentation on :cfunc:`OSVERSIONINFOEX` for more information 0793 about these fields. 0794 0795 Availability: Windows. 0796 0797 """ 0798 return (0, 0) 0799 0800 def setcheckinterval(interval: int): 0801 """ 0802 Set the interpreter's "check interval". This integer value determines how often 0803 the interpreter checks for periodic things such as thread switches and signal 0804 handlers. The default is ``100``, meaning the check is performed every 100 0805 Python virtual instructions. Setting it to a larger value may increase 0806 performance for programs using threads. Setting it to a value ``<=`` 0 checks 0807 every virtual instruction, maximizing responsiveness as well as overhead. 0808 0809 0810 """ 0811 pass 0812 0813 def setdefaultencoding(name): 0814 """ 0815 Set the current default string encoding used by the Unicode implementation. If 0816 *name* does not match any available encoding, :exc:`LookupError` is raised. 0817 This function is only intended to be used by the :mod:`site` module 0818 implementation and, where needed, by :mod:`sitecustomize`. Once used by the 0819 :mod:`site` module, it is removed from the :mod:`sys` module's namespace. 0820 0821 .. mod:`site` is not imported if the :option:`-S` option is passed 0822 to the interpreter, in which case this function will remain available. 0823 0824 """ 0825 pass 0826 0827 def setdlopenflags(n): 0828 """ 0829 Set the flags used by the interpreter for :cfunc:`dlopen` calls, such as when 0830 the interpreter loads extension modules. Among other things, this will enable a 0831 lazy resolving of symbols when importing a module, if called as 0832 ``sys.setdlopenflags(0)``. To share symbols across extension modules, call as 0833 ``sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL)``. Symbolic names for the 0834 flag modules can be either found in the :mod:`dl` module, or in the :mod:`DLFCN` 0835 module. If :mod:`DLFCN` is not available, it can be generated from 0836 :file:`/usr/include/dlfcn.h` using the :program:`h2py` script. Availability: 0837 Unix. 0838 0839 """ 0840 pass 0841 0842 def setprofile(profilefunc): 0843 pass 0844 0845 def setrecursionlimit(limit): 0846 """ 0847 Set the maximum depth of the Python interpreter stack to *limit*. This limit 0848 prevents infinite recursion from causing an overflow of the C stack and crashing 0849 Python. 0850 0851 The highest possible limit is platform-dependent. A user may need to set the 0852 limit higher when she has a program that requires deep recursion and a platform 0853 that supports a higher limit. This should be done with care, because a too-high 0854 limit can lead to a crash. 0855 0856 0857 """ 0858 pass 0859 0860 def settrace(tracefunc): 0861 """ 0862 """ 0863 pass 0864 0865 def settscdump(on_flag): 0866 """ 0867 Activate dumping of VM measurements using the Pentium timestamp counter, if 0868 *on_flag* is true. Deactivate these dumps if *on_flag* is off. The function is 0869 available only if Python was compiled with ``--with-tsc``. To understand 0870 the output of this dump, read :file:`Python/ceval.c` in the Python sources. 0871 0872 """ 0873 pass 0874