Back to index

python3.2  3.2.2
Defines | Functions | Variables
sysmodule.c File Reference
#include "Python.h"
#include "code.h"
#include "frameobject.h"
#include "osdefs.h"

Go to the source code of this file.

Defines

#define SetFlag(flag)   PyStructSequence_SET_ITEM(seq, pos++, PyLong_FromLong(flag))
#define SetIntItem(flag)   PyStructSequence_SET_ITEM(version_info, pos++, PyLong_FromLong(flag))
#define SetStrItem(flag)   PyStructSequence_SET_ITEM(version_info, pos++, PyUnicode_FromString(flag))
#define SET_SYS_FROM_STRING(key, value)
#define _HAVE_SCRIPT_ARGUMENT(argc, argv)

Functions

PyObjectPySys_GetObject (const char *name)
int PySys_SetObject (const char *name, PyObject *v)
static int sys_displayhook_unencodable (PyObject *outf, PyObject *o)
static PyObjectsys_displayhook (PyObject *self, PyObject *o)
 PyDoc_STRVAR (displayhook_doc,"displayhook(object) -> None\n""\n""Print an object to sys.stdout and also save it in builtins._\n")
static PyObjectsys_excepthook (PyObject *self, PyObject *args)
 PyDoc_STRVAR (excepthook_doc,"excepthook(exctype, value, traceback) -> None\n""\n""Handle an exception by displaying it with a traceback on sys.stderr.\n")
static PyObjectsys_exc_info (PyObject *self, PyObject *noargs)
 PyDoc_STRVAR (exc_info_doc,"exc_info() -> (type, value, traceback)\n\ \n\ Return information about the most recent exception caught by an except\n\ clause in the current stack frame or in an older stack frame.")
static PyObjectsys_exit (PyObject *self, PyObject *args)
 PyDoc_STRVAR (exit_doc,"exit([status])\n\ \n\ Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ If the status is numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure).")
static PyObjectsys_getdefaultencoding (PyObject *self)
 PyDoc_STRVAR (getdefaultencoding_doc,"getdefaultencoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ implementation.")
static PyObjectsys_getfilesystemencoding (PyObject *self)
 PyDoc_STRVAR (getfilesystemencoding_doc,"getfilesystemencoding() -> string\n\ \n\ Return the encoding used to convert Unicode filenames in\n\ operating system filenames.")
static PyObjectsys_intern (PyObject *self, PyObject *args)
 PyDoc_STRVAR (intern_doc,"intern(string) -> string\n\ \n\ ``Intern'' the given string. This enters the string in the (global)\n\ table of interned strings whose purpose is to speed up dictionary lookups.\n\ Return the string itself or the previously interned string object with the\n\ same value.")
static int trace_init (void)
static PyObjectcall_trampoline (PyThreadState *tstate, PyObject *callback, PyFrameObject *frame, int what, PyObject *arg)
static int profile_trampoline (PyObject *self, PyFrameObject *frame, int what, PyObject *arg)
static int trace_trampoline (PyObject *self, PyFrameObject *frame, int what, PyObject *arg)
static PyObjectsys_settrace (PyObject *self, PyObject *args)
 PyDoc_STRVAR (settrace_doc,"settrace(function)\n\ \n\ Set the global debug tracing function. It will be called on each\n\ function call. See the debugger chapter in the library manual.")
static PyObjectsys_gettrace (PyObject *self, PyObject *args)
 PyDoc_STRVAR (gettrace_doc,"gettrace()\n\ \n\ Return the global debug tracing function set with sys.settrace.\n\ See the debugger chapter in the library manual.")
static PyObjectsys_setprofile (PyObject *self, PyObject *args)
 PyDoc_STRVAR (setprofile_doc,"setprofile(function)\n\ \n\ Set the profiling function. It will be called on each function call\n\ and return. See the profiler chapter in the library manual.")
static PyObjectsys_getprofile (PyObject *self, PyObject *args)
 PyDoc_STRVAR (getprofile_doc,"getprofile()\n\ \n\ Return the profiling function set with sys.setprofile.\n\ See the profiler chapter in the library manual.")
static PyObjectsys_setcheckinterval (PyObject *self, PyObject *args)
 PyDoc_STRVAR (setcheckinterval_doc,"setcheckinterval(n)\n\ \n\ Tell the Python interpreter to check for asynchronous events every\n\ n instructions. This also affects how often thread switches occur.")
static PyObjectsys_getcheckinterval (PyObject *self, PyObject *args)
 PyDoc_STRVAR (getcheckinterval_doc,"getcheckinterval() -> current check interval; see setcheckinterval().")
static PyObjectsys_setrecursionlimit (PyObject *self, PyObject *args)
 PyDoc_STRVAR (hash_info_doc,"hash_info\n\ \n\ A struct sequence providing parameters used for computing\n\ numeric hashes. The attributes are read only.")
static PyObjectget_hash_info (void)
 PyDoc_STRVAR (setrecursionlimit_doc,"setrecursionlimit(n)\n\ \n\ Set the maximum depth of the Python interpreter stack to n. This\n\ limit prevents infinite recursion from causing an overflow of the C\n\ stack and crashing Python. The highest possible limit is platform-\n\ dependent.")
static PyObjectsys_getrecursionlimit (PyObject *self)
 PyDoc_STRVAR (getrecursionlimit_doc,"getrecursionlimit()\n\ \n\ Return the current value of the recursion limit, the maximum depth\n\ of the Python interpreter stack. This limit prevents infinite\n\ recursion from causing an overflow of the C stack and crashing Python.")
static PyObjectsys_getsizeof (PyObject *self, PyObject *args, PyObject *kwds)
 PyDoc_STRVAR (getsizeof_doc,"getsizeof(object, default) -> int\n\ \n\ Return the size of object in bytes.")
static PyObjectsys_getrefcount (PyObject *self, PyObject *arg)
 PyDoc_STRVAR (getrefcount_doc,"getrefcount(object) -> integer\n\ \n\ Return the reference count of object. The count returned is generally\n\ one higher than you might expect, because it includes the (temporary)\n\ reference as an argument to getrefcount().")
 PyDoc_STRVAR (getframe_doc,"_getframe([depth]) -> frameobject\n\ \n\ Return a frame object from the call stack. If optional integer depth is\n\ given, return the frame object that many calls below the top of the stack.\n\ If that is deeper than the call stack, ValueError is raised. The default\n\ for depth is zero, returning the frame at the top of the call stack.\n\ \n\ This function should be used for internal and specialized\n\ purposes only.")
static PyObjectsys_getframe (PyObject *self, PyObject *args)
 PyDoc_STRVAR (current_frames_doc,"_current_frames() -> dictionary\n\ \n\ Return a dictionary mapping each current thread T's thread id to T's\n\ current stack frame.\n\ \n\ This function should be used for specialized purposes only.")
static PyObjectsys_current_frames (PyObject *self, PyObject *noargs)
 PyDoc_STRVAR (call_tracing_doc,"call_tracing(func, args) -> object\n\ \n\ Call func(*args), while tracing is enabled. The tracing state is\n\ saved, and restored afterwards. This is intended to be called from\n\ a debugger from a checkpoint, to recursively debug some other code.")
static PyObjectsys_call_tracing (PyObject *self, PyObject *args)
 PyDoc_STRVAR (callstats_doc,"callstats() -> tuple of integers\n\ \n\ Return a tuple of function call statistics, if CALL_PROFILE was defined\n\ when Python was built. Otherwise, return None.\n\ \n\ When enabled, this function returns detailed, implementation-specific\n\ details about the number of function calls executed. The return value is\n\ a 11-tuple where the entries in the tuple are counts of:\n\ 0. all function calls\n\ 1. calls to PyFunction_Type objects\n\ 2. PyFunction calls that do not create an argument tuple\n\ 3. PyFunction calls that do not create an argument tuple\n\ and bypass PyEval_EvalCodeEx()\n\ 4. PyMethod calls\n\ 5. PyMethod calls on bound methods\n\ 6. PyType calls\n\ 7. PyCFunction calls\n\ 8. generator calls\n\ 9. All other calls\n\ 10. Number of stack pops performed by call_function()")
static PyObjectsys_clear_type_cache (PyObject *self, PyObject *args)
 PyDoc_STRVAR (sys_clear_type_cache__doc__,"_clear_type_cache() -> None\n\ Clear the internal type lookup cache.")
static PyObjectlist_builtin_module_names (void)
void PySys_ResetWarnOptions (void)
void PySys_AddWarnOptionUnicode (PyObject *unicode)
void PySys_AddWarnOption (const wchar_t *s)
int PySys_HasWarnOptions (void)
static PyObjectget_xoptions (void)
void PySys_AddXOption (const wchar_t *s)
PyObjectPySys_GetXOptions (void)
 PyDoc_VAR (sys_doc)
static void svnversion_init (void)
const char * Py_SubversionRevision ()
const char * Py_SubversionShortBranch ()
 PyDoc_STRVAR (flags__doc__,"sys.flags\n\ \n\ Flags provided through command line arguments or environment vars.")
static PyObjectmake_flags (void)
 PyDoc_STRVAR (version_info__doc__,"sys.version_info\n\ \n\ Version information as a named tuple.")
static PyObjectmake_version_info (void)
PyObject_PySys_Init (void)
static PyObjectmakepathobject (const wchar_t *path, wchar_t delim)
void PySys_SetPath (const wchar_t *path)
static PyObjectmakeargvobject (int argc, wchar_t **argv)
static void sys_update_path (int argc, wchar_t **argv)
void PySys_SetArgvEx (int argc, wchar_t **argv, int updatepath)
void PySys_SetArgv (int argc, wchar_t **argv)
static int sys_pyfile_write_unicode (PyObject *unicode, PyObject *file)
static int sys_pyfile_write (const char *text, PyObject *file)
static void sys_write (char *name, FILE *fp, const char *format, va_list va)
void PySys_WriteStdout (const char *format,...)
void PySys_WriteStderr (const char *format,...)
static void sys_format (char *name, FILE *fp, const char *format, va_list va)
void PySys_FormatStdout (const char *format,...)
void PySys_FormatStderr (const char *format,...)

Variables

static PyObjectwhatstrings [7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}
static int _check_interval = 100
static PyTypeObject Hash_InfoType
static PyStructSequence_Field hash_info_fields []
static PyStructSequence_Desc hash_info_desc
static PyMethodDef sys_methods []
static PyObjectwarnoptions = NULL
static PyObjectxoptions = NULL
static int svn_initialized
static char patchlevel_revision [50]
static char branch [50]
static char shortbranch [50]
static const char * svn_revision
static PyTypeObject FlagsType
static PyStructSequence_Field flags_fields []
static PyStructSequence_Desc flags_desc
static PyTypeObject VersionInfoType
static PyStructSequence_Field version_info_fields []
static PyStructSequence_Desc version_info_desc
static struct PyModuleDef

Define Documentation

#define _HAVE_SCRIPT_ARGUMENT (   argc,
  argv 
)
Value:
(argc > 0 && argv0 != NULL && \
   wcscmp(argv0, L"-c") != 0 && wcscmp(argv0, L"-m") != 0)

Definition at line 1750 of file sysmodule.c.

#define SET_SYS_FROM_STRING (   key,
  value 
)
Value:
v = value;                                          \
    if (v != NULL)                                      \
        PyDict_SetItemString(sysdict, key, v);          \
    Py_XDECREF(v)
#define SetFlag (   flag)    PyStructSequence_SET_ITEM(seq, pos++, PyLong_FromLong(flag))
#define SetIntItem (   flag)    PyStructSequence_SET_ITEM(version_info, pos++, PyLong_FromLong(flag))
#define SetStrItem (   flag)    PyStructSequence_SET_ITEM(version_info, pos++, PyUnicode_FromString(flag))

Function Documentation

Definition at line 1505 of file sysmodule.c.

{
    PyObject *m, *v, *sysdict;
    char *s;

    m = PyModule_Create(&sysmodule);
    if (m == NULL)
        return NULL;
    sysdict = PyModule_GetDict(m);
#define SET_SYS_FROM_STRING(key, value)                 \
    v = value;                                          \
    if (v != NULL)                                      \
        PyDict_SetItemString(sysdict, key, v);          \
    Py_XDECREF(v)

    /* Check that stdin is not a directory
    Using shell redirection, you can redirect stdin to a directory,
    crashing the Python interpreter. Catch this common mistake here
    and output a useful error message. Note that under MS Windows,
    the shell already prevents that. */
#if !defined(MS_WINDOWS)
    {
        struct stat sb;
        if (fstat(fileno(stdin), &sb) == 0 &&
            S_ISDIR(sb.st_mode)) {
            /* There's nothing more we can do. */
            /* Py_FatalError() will core dump, so just exit. */
            PySys_WriteStderr("Python error: <stdin> is a directory, cannot continue\n");
            exit(EXIT_FAILURE);
        }
    }
#endif

    /* stdin/stdout/stderr are now set by pythonrun.c */

    PyDict_SetItemString(sysdict, "__displayhook__",
                         PyDict_GetItemString(sysdict, "displayhook"));
    PyDict_SetItemString(sysdict, "__excepthook__",
                         PyDict_GetItemString(sysdict, "excepthook"));
    SET_SYS_FROM_STRING("version",
                         PyUnicode_FromString(Py_GetVersion()));
    SET_SYS_FROM_STRING("hexversion",
                         PyLong_FromLong(PY_VERSION_HEX));
    svnversion_init();
    SET_SYS_FROM_STRING("subversion",
                        Py_BuildValue("(sss)", "CPython", branch,
                                      svn_revision));
    SET_SYS_FROM_STRING("_mercurial",
                        Py_BuildValue("(szz)", "CPython", _Py_hgidentifier(),
                                      _Py_hgversion()));
    SET_SYS_FROM_STRING("dont_write_bytecode",
                         PyBool_FromLong(Py_DontWriteBytecodeFlag));
    SET_SYS_FROM_STRING("api_version",
                        PyLong_FromLong(PYTHON_API_VERSION));
    SET_SYS_FROM_STRING("copyright",
                        PyUnicode_FromString(Py_GetCopyright()));
    SET_SYS_FROM_STRING("platform",
                        PyUnicode_FromString(Py_GetPlatform()));
    SET_SYS_FROM_STRING("executable",
                        PyUnicode_FromWideChar(
                               Py_GetProgramFullPath(), -1));
    SET_SYS_FROM_STRING("prefix",
                        PyUnicode_FromWideChar(Py_GetPrefix(), -1));
    SET_SYS_FROM_STRING("exec_prefix",
                        PyUnicode_FromWideChar(Py_GetExecPrefix(), -1));
    SET_SYS_FROM_STRING("maxsize",
                        PyLong_FromSsize_t(PY_SSIZE_T_MAX));
    SET_SYS_FROM_STRING("float_info",
                        PyFloat_GetInfo());
    SET_SYS_FROM_STRING("int_info",
                        PyLong_GetInfo());
    /* initialize hash_info */
    if (Hash_InfoType.tp_name == 0)
        PyStructSequence_InitType(&Hash_InfoType, &hash_info_desc);
    SET_SYS_FROM_STRING("hash_info",
                        get_hash_info());
    SET_SYS_FROM_STRING("maxunicode",
                        PyLong_FromLong(PyUnicode_GetMax()));
    SET_SYS_FROM_STRING("builtin_module_names",
                        list_builtin_module_names());
    {
        /* Assumes that longs are at least 2 bytes long.
           Should be safe! */
        unsigned long number = 1;
        char *value;

        s = (char *) &number;
        if (s[0] == 0)
            value = "big";
        else
            value = "little";
        SET_SYS_FROM_STRING("byteorder",
                            PyUnicode_FromString(value));
    }
#ifdef MS_COREDLL
    SET_SYS_FROM_STRING("dllhandle",
                        PyLong_FromVoidPtr(PyWin_DLLhModule));
    SET_SYS_FROM_STRING("winver",
                        PyUnicode_FromString(PyWin_DLLVersionString));
#endif
#ifdef ABIFLAGS
    SET_SYS_FROM_STRING("abiflags",
                        PyUnicode_FromString(ABIFLAGS));
#endif
    if (warnoptions == NULL) {
        warnoptions = PyList_New(0);
    }
    else {
        Py_INCREF(warnoptions);
    }
    if (warnoptions != NULL) {
        PyDict_SetItemString(sysdict, "warnoptions", warnoptions);
    }

    v = get_xoptions();
    if (v != NULL) {
        PyDict_SetItemString(sysdict, "_xoptions", v);
    }

    /* version_info */
    if (VersionInfoType.tp_name == 0)
        PyStructSequence_InitType(&VersionInfoType, &version_info_desc);
    SET_SYS_FROM_STRING("version_info", make_version_info());
    /* prevent user from creating new instances */
    VersionInfoType.tp_init = NULL;
    VersionInfoType.tp_new = NULL;

    /* flags */
    if (FlagsType.tp_name == 0)
        PyStructSequence_InitType(&FlagsType, &flags_desc);
    SET_SYS_FROM_STRING("flags", make_flags());
    /* prevent user from creating new instances */
    FlagsType.tp_init = NULL;
    FlagsType.tp_new = NULL;


#if defined(MS_WINDOWS)
    /* getwindowsversion */
    if (WindowsVersionType.tp_name == 0)
        PyStructSequence_InitType(&WindowsVersionType, &windows_version_desc);
    /* prevent user from creating new instances */
    WindowsVersionType.tp_init = NULL;
    WindowsVersionType.tp_new = NULL;
#endif

    /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
#ifndef PY_NO_SHORT_FLOAT_REPR
    SET_SYS_FROM_STRING("float_repr_style",
                        PyUnicode_FromString("short"));
#else
    SET_SYS_FROM_STRING("float_repr_style",
                        PyUnicode_FromString("legacy"));
#endif

#undef SET_SYS_FROM_STRING
    if (PyErr_Occurred())
        return NULL;
    return m;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* call_trampoline ( PyThreadState tstate,
PyObject callback,
PyFrameObject frame,
int  what,
PyObject arg 
) [static]

Definition at line 327 of file sysmodule.c.

{
    PyObject *args = PyTuple_New(3);
    PyObject *whatstr;
    PyObject *result;

    if (args == NULL)
        return NULL;
    Py_INCREF(frame);
    whatstr = whatstrings[what];
    Py_INCREF(whatstr);
    if (arg == NULL)
        arg = Py_None;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, (PyObject *)frame);
    PyTuple_SET_ITEM(args, 1, whatstr);
    PyTuple_SET_ITEM(args, 2, arg);

    /* call the Python-level function */
    PyFrame_FastToLocals(frame);
    result = PyEval_CallObject(callback, args);
    PyFrame_LocalsToFast(frame, 1);
    if (result == NULL)
        PyTraceBack_Here(frame);

    /* cleanup */
    Py_DECREF(args);
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* get_hash_info ( void  ) [static]

Definition at line 635 of file sysmodule.c.

{
    PyObject *hash_info;
    int field = 0;
    hash_info = PyStructSequence_New(&Hash_InfoType);
    if (hash_info == NULL)
        return NULL;
    PyStructSequence_SET_ITEM(hash_info, field++,
                              PyLong_FromLong(8*sizeof(Py_hash_t)));
    PyStructSequence_SET_ITEM(hash_info, field++,
                              PyLong_FromSsize_t(_PyHASH_MODULUS));
    PyStructSequence_SET_ITEM(hash_info, field++,
                              PyLong_FromLong(_PyHASH_INF));
    PyStructSequence_SET_ITEM(hash_info, field++,
                              PyLong_FromLong(_PyHASH_NAN));
    PyStructSequence_SET_ITEM(hash_info, field++,
                              PyLong_FromLong(_PyHASH_IMAG));
    if (PyErr_Occurred()) {
        Py_CLEAR(hash_info);
        return NULL;
    }
    return hash_info;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* get_xoptions ( void  ) [static]

Definition at line 1165 of file sysmodule.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* list_builtin_module_names ( void  ) [static]

Definition at line 1097 of file sysmodule.c.

{
    PyObject *list = PyList_New(0);
    int i;
    if (list == NULL)
        return NULL;
    for (i = 0; PyImport_Inittab[i].name != NULL; i++) {
        PyObject *name = PyUnicode_FromString(
            PyImport_Inittab[i].name);
        if (name == NULL)
            break;
        PyList_Append(list, name);
        Py_DECREF(name);
    }
    if (PyList_Sort(list) != 0) {
        Py_DECREF(list);
        list = NULL;
    }
    if (list) {
        PyObject *v = PyList_AsTuple(list);
        Py_DECREF(list);
        list = v;
    }
    return list;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* make_flags ( void  ) [static]

Definition at line 1386 of file sysmodule.c.

{
    int pos = 0;
    PyObject *seq;

    seq = PyStructSequence_New(&FlagsType);
    if (seq == NULL)
        return NULL;

#define SetFlag(flag) \
    PyStructSequence_SET_ITEM(seq, pos++, PyLong_FromLong(flag))

    SetFlag(Py_DebugFlag);
    SetFlag(Py_DivisionWarningFlag);
    SetFlag(Py_InspectFlag);
    SetFlag(Py_InteractiveFlag);
    SetFlag(Py_OptimizeFlag);
    SetFlag(Py_DontWriteBytecodeFlag);
    SetFlag(Py_NoUserSiteDirectory);
    SetFlag(Py_NoSiteFlag);
    SetFlag(Py_IgnoreEnvironmentFlag);
    SetFlag(Py_VerboseFlag);
#ifdef RISCOS
    SetFlag(Py_RISCOSWimpFlag);
#endif
    /* SetFlag(saw_unbuffered_flag); */
    /* SetFlag(skipfirstline); */
    SetFlag(Py_BytesWarningFlag);
    SetFlag(Py_QuietFlag);
#undef SetFlag

    if (PyErr_Occurred()) {
        return NULL;
    }
    return seq;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* make_version_info ( void  ) [static]

Definition at line 1447 of file sysmodule.c.

{
    PyObject *version_info;
    char *s;
    int pos = 0;

    version_info = PyStructSequence_New(&VersionInfoType);
    if (version_info == NULL) {
        return NULL;
    }

    /*
     * These release level checks are mutually exclusive and cover
     * the field, so don't get too fancy with the pre-processor!
     */
#if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA
    s = "alpha";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_BETA
    s = "beta";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_GAMMA
    s = "candidate";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL
    s = "final";
#endif

#define SetIntItem(flag) \
    PyStructSequence_SET_ITEM(version_info, pos++, PyLong_FromLong(flag))
#define SetStrItem(flag) \
    PyStructSequence_SET_ITEM(version_info, pos++, PyUnicode_FromString(flag))

    SetIntItem(PY_MAJOR_VERSION);
    SetIntItem(PY_MINOR_VERSION);
    SetIntItem(PY_MICRO_VERSION);
    SetStrItem(s);
    SetIntItem(PY_RELEASE_SERIAL);
#undef SetIntItem
#undef SetStrItem

    if (PyErr_Occurred()) {
        Py_CLEAR(version_info);
        return NULL;
    }
    return version_info;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* makeargvobject ( int  argc,
wchar_t **  argv 
) [static]

Definition at line 1710 of file sysmodule.c.

{
    PyObject *av;
    if (argc <= 0 || argv == NULL) {
        /* Ensure at least one (empty) argument is seen */
        static wchar_t *empty_argv[1] = {L""};
        argv = empty_argv;
        argc = 1;
    }
    av = PyList_New(argc);
    if (av != NULL) {
        int i;
        for (i = 0; i < argc; i++) {
#ifdef __VMS
            PyObject *v;

            /* argv[0] is the script pathname if known */
            if (i == 0) {
                char* fn = decc$translate_vms(argv[0]);
                if ((fn == (char *)0) || fn == (char *)-1)
                    v = PyUnicode_FromString(argv[0]);
                else
                    v = PyUnicode_FromString(
                        decc$translate_vms(argv[0]));
            } else
                v = PyUnicode_FromString(argv[i]);
#else
            PyObject *v = PyUnicode_FromWideChar(argv[i], -1);
#endif
            if (v == NULL) {
                Py_DECREF(av);
                av = NULL;
                break;
            }
            PyList_SetItem(av, i, v);
        }
    }
    return av;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* makepathobject ( const wchar_t *  path,
wchar_t  delim 
) [static]

Definition at line 1666 of file sysmodule.c.

{
    int i, n;
    const wchar_t *p;
    PyObject *v, *w;

    n = 1;
    p = path;
    while ((p = wcschr(p, delim)) != NULL) {
        n++;
        p++;
    }
    v = PyList_New(n);
    if (v == NULL)
        return NULL;
    for (i = 0; ; i++) {
        p = wcschr(path, delim);
        if (p == NULL)
            p = path + wcslen(path); /* End of string */
        w = PyUnicode_FromWideChar(path, (Py_ssize_t)(p - path));
        if (w == NULL) {
            Py_DECREF(v);
            return NULL;
        }
        PyList_SetItem(v, i, w);
        if (*p == '\0')
            break;
        path = p+1;
    }
    return v;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int profile_trampoline ( PyObject self,
PyFrameObject frame,
int  what,
PyObject arg 
) [static]

Definition at line 359 of file sysmodule.c.

{
    PyThreadState *tstate = frame->f_tstate;
    PyObject *result;

    if (arg == NULL)
        arg = Py_None;
    result = call_trampoline(tstate, self, frame, what, arg);
    if (result == NULL) {
        PyEval_SetProfile(NULL, NULL);
        return -1;
    }
    Py_DECREF(result);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1332 of file sysmodule.c.

Here is the call graph for this function:

Definition at line 1339 of file sysmodule.c.

Here is the call graph for this function:

PyDoc_STRVAR ( displayhook_doc  ,
"displayhook(object) -> None\n""\n""Print an object to sys.stdout and also save it in builtins._\n  
)
PyDoc_STRVAR ( excepthook_doc  ,
"excepthook(exctype, value, traceback) -> None\n""\n""Handle an exception by displaying it with a traceback on sys.stderr.\n  
)
PyDoc_STRVAR ( exc_info_doc  ,
"exc_info() -> (type, value, traceback)\n\\n\Return information about the most recent exception caught by an except\n\clause in the current stack frame or in an older stack frame."   
)
PyDoc_STRVAR ( exit_doc  ,
"exit([status])\n\\n\Exit the interpreter by raising SystemExit(status).\n\If the status is omitted or  None,
it defaults to zero(i.e., success).\n\If the status is  numeric,
it will be used as the system exit status.\n\If it is another kind of  object,
it will be printed and the system\n\exit status will be one(i.e., failure)."   
)
PyDoc_STRVAR ( getdefaultencoding_doc  ,
"getdefaultencoding() -> string\n\\n\Return the current default string encoding used by the Unicode \n\implementation."   
)
PyDoc_STRVAR ( getfilesystemencoding_doc  ,
"getfilesystemencoding() -> string\n\\n\Return the encoding used to convert Unicode filenames in\n\operating system filenames."   
)
PyDoc_STRVAR ( intern_doc  ,
"intern(string) -> string\n\\n\``Intern'' the given string. This enters the string in the (global)\n\table of interned strings whose purpose is to speed up dictionary lookups.\n\Return the string itself or the previously interned string object with the\n\same value."   
)
PyDoc_STRVAR ( settrace_doc  ,
"settrace(function)\n\\n\Set the global debug tracing function. It will be called on each\n\function call. See the debugger chapter in the library manual."   
)
PyDoc_STRVAR ( gettrace_doc  ,
"gettrace()\n\\n\Return the global debug tracing function set with sys.settrace.\n\See the debugger chapter in the library manual."   
)
PyDoc_STRVAR ( setprofile_doc  ,
"setprofile(function)\n\\n\Set the profiling function. It will be called on each function call\n\and return. See the profiler chapter in the library manual."   
)
PyDoc_STRVAR ( getprofile_doc  ,
"getprofile()\n\\n\Return the profiling function set with sys.setprofile.\n\See the profiler chapter in the library manual."   
)
PyDoc_STRVAR ( setcheckinterval_doc  ,
"setcheckinterval(n)\n\\n\Tell the Python interpreter to check for asynchronous events every\n\n instructions. This also affects how often thread switches occur."   
)
PyDoc_STRVAR ( getcheckinterval_doc  ,
"getcheckinterval() -> current check interval; see setcheckinterval()."   
)
PyDoc_STRVAR ( hash_info_doc  ,
"hash_info\n\\n\A struct sequence providing parameters used for computing\n\numeric hashes. The attributes are read only."   
)
PyDoc_STRVAR ( setrecursionlimit_doc  ,
"setrecursionlimit(n)\n\\n\Set the maximum depth of the Python interpreter stack to n. This\n\limit prevents infinite recursion from causing an overflow of the C\n\stack and crashing Python. The highest possible limit is platform-\n\dependent."   
)
PyDoc_STRVAR ( getrecursionlimit_doc  ,
"getrecursionlimit()\n\\n\Return the current value of the recursion  limit,
the maximum depth\n\of the Python interpreter stack.This limit prevents infinite\n\recursion from causing an overflow of the C stack and crashing Python."   
)
PyDoc_STRVAR ( getsizeof_doc  ,
"getsizeof(object, default) -> int\n\\n\Return the size of object in bytes."   
)
PyDoc_STRVAR ( getrefcount_doc  ,
"getrefcount(object) -> integer\n\\n\Return the reference count of object. The count returned is generally\n\one higher than you might  expect,
because it includes the(temporary)\n\reference as an argument to getrefcount()."   
)
PyDoc_STRVAR ( getframe_doc  ,
"_getframe([depth]) -> frameobject\n\\n\Return a frame object from the call stack. If optional integer depth is\n\  given,
return the frame object that many calls below the top of the stack.\n\If that is deeper than the call  stack,
ValueError is raised.The default\n\for depth is  zero,
returning the frame at the top of the call stack.\n\\n\This function should be used for internal and specialized\n\purposes only."   
)
PyDoc_STRVAR ( current_frames_doc  ,
"_current_frames() -> dictionary\n\\n\Return a dictionary mapping each current thread T's thread id to T's\n\current stack frame.\n\\n\This function should be used for specialized purposes only."   
)
PyDoc_STRVAR ( call_tracing_doc  ,
"call_tracing(func, args) -> object\n\\n\Call func*  args,
while tracing is enabled.The tracing state is\n\  saved,
and restored afterwards.This is intended to be called from\n\a debugger from a  checkpoint,
to recursively debug some other code."   
)
PyDoc_STRVAR ( callstats_doc  ,
"callstats() -> tuple of integers\n\\n\Return a tuple of function call  statistics,
if CALL_PROFILE was defined\n\when Python was built.  Otherwise,
return None.\n\\n\When  enabled,
this function returns  detailed,
implementation-specific\n\details about the number of function calls executed.The return value is\n\a 11-tuple where the entries in the tuple are counts of:\n\0.all function calls\n\1.calls to PyFunction_Type objects\n\2.PyFunction calls that do not create an argument tuple\n\3.PyFunction calls that do not create an argument tuple\n\and bypass PyEval_EvalCodeEx()\n\4.PyMethod calls\n\5.PyMethod calls on bound methods\n\6.PyType calls\n\7.PyCFunction calls\n\8.generator calls\n\9.All other calls\n\10.Number of stack pops performed by call_function()"   
)
PyDoc_STRVAR ( sys_clear_type_cache__doc__  ,
"_clear_type_cache() -> None\n\Clear the internal type lookup cache."   
)
PyDoc_STRVAR ( flags__doc__  ,
"sys.flags\n\\n\Flags provided through command line arguments or environment vars."   
)
PyDoc_STRVAR ( version_info__doc__  ,
"sys.version_info\n\\n\Version information as a named tuple."   
)
PyDoc_VAR ( sys_doc  )
void PySys_AddWarnOption ( const wchar_t *  s)

Definition at line 1146 of file sysmodule.c.

{
    PyObject *unicode;
    unicode = PyUnicode_FromWideChar(s, -1);
    if (unicode == NULL)
        return;
    PySys_AddWarnOptionUnicode(unicode);
    Py_DECREF(unicode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1134 of file sysmodule.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void PySys_AddXOption ( const wchar_t *  s)

Definition at line 1175 of file sysmodule.c.

{
    PyObject *opts;
    PyObject *name = NULL, *value = NULL;
    const wchar_t *name_end;
    int r;

    opts = get_xoptions();
    if (opts == NULL)
        goto error;

    name_end = wcschr(s, L'=');
    if (!name_end) {
        name = PyUnicode_FromWideChar(s, -1);
        value = Py_True;
        Py_INCREF(value);
    }
    else {
        name = PyUnicode_FromWideChar(s, name_end - s);
        value = PyUnicode_FromWideChar(name_end + 1, -1);
    }
    if (name == NULL || value == NULL)
        goto error;
    r = PyDict_SetItem(opts, name, value);
    Py_DECREF(name);
    Py_DECREF(value);
    return;

error:
    Py_XDECREF(name);
    Py_XDECREF(value);
    /* No return value, therefore clear error state if possible */
    if (_Py_atomic_load_relaxed(&_PyThreadState_Current))
        PyErr_Clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PySys_FormatStderr ( const char *  format,
  ... 
)

Definition at line 2033 of file sysmodule.c.

{
    va_list va;

    va_start(va, format);
    sys_format("stderr", stderr, format, va);
    va_end(va);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PySys_FormatStdout ( const char *  format,
  ... 
)

Definition at line 2023 of file sysmodule.c.

{
    va_list va;

    va_start(va, format);
    sys_format("stdout", stdout, format, va);
    va_end(va);
}

Here is the call graph for this function:

PyObject* PySys_GetObject ( const char *  name)

Definition at line 44 of file sysmodule.c.

{
    PyThreadState *tstate = PyThreadState_GET();
    PyObject *sd = tstate->interp->sysdict;
    if (sd == NULL)
        return NULL;
    return PyDict_GetItemString(sd, name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1212 of file sysmodule.c.

{
    return get_xoptions();
}

Here is the call graph for this function:

Definition at line 1157 of file sysmodule.c.

{
    return (warnoptions != NULL && (PyList_Size(warnoptions) > 0)) ? 1 : 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1126 of file sysmodule.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void PySys_SetArgv ( int  argc,
wchar_t **  argv 
)

Definition at line 1869 of file sysmodule.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void PySys_SetArgvEx ( int  argc,
wchar_t **  argv,
int  updatepath 
)

Definition at line 1856 of file sysmodule.c.

{
    PyObject *av = makeargvobject(argc, argv);
    if (av == NULL)
        Py_FatalError("no mem for sys.argv");
    if (PySys_SetObject("argv", av) != 0)
        Py_FatalError("can't assign sys.argv");
    Py_DECREF(av);
    if (updatepath)
        sys_update_path(argc, argv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int PySys_SetObject ( const char *  name,
PyObject v 
)

Definition at line 54 of file sysmodule.c.

{
    PyThreadState *tstate = PyThreadState_GET();
    PyObject *sd = tstate->interp->sysdict;
    if (v == NULL) {
        if (PyDict_GetItemString(sd, name) == NULL)
            return 0;
        else
            return PyDict_DelItemString(sd, name);
    }
    else
        return PyDict_SetItemString(sd, name, v);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PySys_SetPath ( const wchar_t *  path)

Definition at line 1699 of file sysmodule.c.

{
    PyObject *v;
    if ((v = makepathobject(path, DELIM)) == NULL)
        Py_FatalError("can't create sys.path");
    if (PySys_SetObject("path", v) != 0)
        Py_FatalError("can't assign sys.path");
    Py_DECREF(v);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PySys_WriteStderr ( const char *  format,
  ... 
)

Definition at line 1991 of file sysmodule.c.

{
    va_list va;

    va_start(va, format);
    sys_write("stderr", stderr, format, va);
    va_end(va);
}

Here is the call graph for this function:

void PySys_WriteStdout ( const char *  format,
  ... 
)

Definition at line 1981 of file sysmodule.c.

{
    va_list va;

    va_start(va, format);
    sys_write("stdout", stdout, format, va);
    va_end(va);
}

Here is the call graph for this function:

static void svnversion_init ( void  ) [static]

Definition at line 1316 of file sysmodule.c.

{
    if (svn_initialized)
        return;

    svn_initialized = 1;
    *patchlevel_revision = '\0';
    strcpy(branch, "");
    strcpy(shortbranch, "unknown");
    svn_revision = "";
}

Here is the caller graph for this function:

static PyObject* sys_call_tracing ( PyObject self,
PyObject args 
) [static]

Definition at line 962 of file sysmodule.c.

{
    PyObject *func, *funcargs;
    if (!PyArg_ParseTuple(args, "OO!:call_tracing", &func, &PyTuple_Type, &funcargs))
        return NULL;
    return _PyEval_CallTracing(func, funcargs);
}

Here is the call graph for this function:

static PyObject* sys_clear_type_cache ( PyObject self,
PyObject args 
) [static]

Definition at line 1012 of file sysmodule.c.

Here is the call graph for this function:

static PyObject* sys_current_frames ( PyObject self,
PyObject noargs 
) [static]

Definition at line 948 of file sysmodule.c.

Here is the call graph for this function:

static PyObject* sys_displayhook ( PyObject self,
PyObject o 
) [static]

Definition at line 131 of file sysmodule.c.

{
    PyObject *outf;
    PyInterpreterState *interp = PyThreadState_GET()->interp;
    PyObject *modules = interp->modules;
    PyObject *builtins = PyDict_GetItemString(modules, "builtins");
    int err;

    if (builtins == NULL) {
        PyErr_SetString(PyExc_RuntimeError, "lost builtins module");
        return NULL;
    }

    /* Print value except if None */
    /* After printing, also assign to '_' */
    /* Before, set '_' to None to avoid recursion */
    if (o == Py_None) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    if (PyObject_SetAttrString(builtins, "_", Py_None) != 0)
        return NULL;
    outf = PySys_GetObject("stdout");
    if (outf == NULL || outf == Py_None) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
        return NULL;
    }
    if (PyFile_WriteObject(o, outf, 0) != 0) {
        if (PyErr_ExceptionMatches(PyExc_UnicodeEncodeError)) {
            /* repr(o) is not encodable to sys.stdout.encoding with
             * sys.stdout.errors error handler (which is probably 'strict') */
            PyErr_Clear();
            err = sys_displayhook_unencodable(outf, o);
            if (err)
                return NULL;
        }
        else {
            return NULL;
        }
    }
    if (PyFile_WriteString("\n", outf) != 0)
        return NULL;
    if (PyObject_SetAttrString(builtins, "_", o) != 0)
        return NULL;
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static int sys_displayhook_unencodable ( PyObject outf,
PyObject o 
) [static]

Definition at line 75 of file sysmodule.c.

{
    PyObject *stdout_encoding = NULL;
    PyObject *encoded, *escaped_str, *repr_str, *buffer, *result;
    char *stdout_encoding_str;
    int ret;

    stdout_encoding = PyObject_GetAttrString(outf, "encoding");
    if (stdout_encoding == NULL)
        goto error;
    stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
    if (stdout_encoding_str == NULL)
        goto error;

    repr_str = PyObject_Repr(o);
    if (repr_str == NULL)
        goto error;
    encoded = PyUnicode_AsEncodedString(repr_str,
                                        stdout_encoding_str,
                                        "backslashreplace");
    Py_DECREF(repr_str);
    if (encoded == NULL)
        goto error;

    buffer = PyObject_GetAttrString(outf, "buffer");
    if (buffer) {
        result = PyObject_CallMethod(buffer, "write", "(O)", encoded);
        Py_DECREF(buffer);
        Py_DECREF(encoded);
        if (result == NULL)
            goto error;
        Py_DECREF(result);
    }
    else {
        PyErr_Clear();
        escaped_str = PyUnicode_FromEncodedObject(encoded,
                                                  stdout_encoding_str,
                                                  "strict");
        Py_DECREF(encoded);
        if (PyFile_WriteObject(escaped_str, outf, Py_PRINT_RAW) != 0) {
            Py_DECREF(escaped_str);
            goto error;
        }
        Py_DECREF(escaped_str);
    }
    ret = 0;
    goto finally;

error:
    ret = -1;
finally:
    Py_XDECREF(stdout_encoding);
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* sys_exc_info ( PyObject self,
PyObject noargs 
) [static]

Definition at line 203 of file sysmodule.c.

{
    PyThreadState *tstate;
    tstate = PyThreadState_GET();
    return Py_BuildValue(
        "(OOO)",
        tstate->exc_type != NULL ? tstate->exc_type : Py_None,
        tstate->exc_value != NULL ? tstate->exc_value : Py_None,
        tstate->exc_traceback != NULL ?
            tstate->exc_traceback : Py_None);
}

Here is the call graph for this function:

static PyObject* sys_excepthook ( PyObject self,
PyObject args 
) [static]

Definition at line 186 of file sysmodule.c.

{
    PyObject *exc, *value, *tb;
    if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb))
        return NULL;
    PyErr_Display(exc, value, tb);
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* sys_exit ( PyObject self,
PyObject args 
) [static]

Definition at line 223 of file sysmodule.c.

{
    PyObject *exit_code = 0;
    if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code))
        return NULL;
    /* Raise SystemExit so callers may catch it or clean up. */
    PyErr_SetObject(PyExc_SystemExit, exit_code);
    return NULL;
}

Here is the call graph for this function:

static void sys_format ( char *  name,
FILE *  fp,
const char *  format,
va_list  va 
) [static]

Definition at line 2001 of file sysmodule.c.

{
    PyObject *file, *message;
    PyObject *error_type, *error_value, *error_traceback;
    char *utf8;

    PyErr_Fetch(&error_type, &error_value, &error_traceback);
    file = PySys_GetObject(name);
    message = PyUnicode_FromFormatV(format, va);
    if (message != NULL) {
        if (sys_pyfile_write_unicode(message, file) != 0) {
            PyErr_Clear();
            utf8 = _PyUnicode_AsString(message);
            if (utf8 != NULL)
                fputs(utf8, fp);
        }
        Py_DECREF(message);
    }
    PyErr_Restore(error_type, error_value, error_traceback);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* sys_getcheckinterval ( PyObject self,
PyObject args 
) [static]

Definition at line 511 of file sysmodule.c.

{
    if (PyErr_WarnEx(PyExc_DeprecationWarning,
                     "sys.getcheckinterval() and sys.setcheckinterval() "
                     "are deprecated.  Use sys.getswitchinterval() "
                     "instead.", 1) < 0)
        return NULL;
    return PyLong_FromLong(_check_interval);
}

Here is the call graph for this function:

static PyObject* sys_getdefaultencoding ( PyObject self) [static]

Definition at line 245 of file sysmodule.c.

Here is the call graph for this function:

static PyObject* sys_getfilesystemencoding ( PyObject self) [static]

Definition at line 258 of file sysmodule.c.

{
    if (Py_FileSystemDefaultEncoding)
        return PyUnicode_FromString(Py_FileSystemDefaultEncoding);
    PyErr_SetString(PyExc_RuntimeError,
                    "filesystem encoding is not initialized");
    return NULL;
}

Here is the call graph for this function:

static PyObject* sys_getframe ( PyObject self,
PyObject args 
) [static]

Definition at line 917 of file sysmodule.c.

{
    PyFrameObject *f = PyThreadState_GET()->frame;
    int depth = -1;

    if (!PyArg_ParseTuple(args, "|i:_getframe", &depth))
        return NULL;

    while (depth > 0 && f != NULL) {
        f = f->f_back;
        --depth;
    }
    if (f == NULL) {
        PyErr_SetString(PyExc_ValueError,
                        "call stack is not deep enough");
        return NULL;
    }
    Py_INCREF(f);
    return (PyObject*)f;
}

Here is the call graph for this function:

static PyObject* sys_getprofile ( PyObject self,
PyObject args 
) [static]

Definition at line 469 of file sysmodule.c.

{
    PyThreadState *tstate = PyThreadState_GET();
    PyObject *temp = tstate->c_profileobj;

    if (temp == NULL)
        temp = Py_None;
    Py_INCREF(temp);
    return temp;
}
static PyObject* sys_getrecursionlimit ( PyObject self) [static]

Definition at line 670 of file sysmodule.c.

Here is the call graph for this function:

static PyObject* sys_getrefcount ( PyObject self,
PyObject arg 
) [static]

Definition at line 873 of file sysmodule.c.

{
    return PyLong_FromSsize_t(arg->ob_refcnt);
}
static PyObject* sys_getsizeof ( PyObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 811 of file sysmodule.c.

{
    PyObject *res = NULL;
    static PyObject *str__sizeof__ = NULL, *gc_head_size = NULL;
    static char *kwlist[] = {"object", "default", 0};
    PyObject *o, *dflt = NULL;
    PyObject *method;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:getsizeof",
                                     kwlist, &o, &dflt))
        return NULL;

    /* Initialize static variable for GC head size */
    if (gc_head_size == NULL) {
        gc_head_size = PyLong_FromSsize_t(sizeof(PyGC_Head));
        if (gc_head_size == NULL)
            return NULL;
    }

    /* Make sure the type is initialized. float gets initialized late */
    if (PyType_Ready(Py_TYPE(o)) < 0)
        return NULL;

    method = _PyObject_LookupSpecial(o, "__sizeof__",
                                     &str__sizeof__);
    if (method == NULL) {
        if (!PyErr_Occurred())
            PyErr_Format(PyExc_TypeError,
                         "Type %.100s doesn't define __sizeof__",
                         Py_TYPE(o)->tp_name);
    }
    else {
        res = PyObject_CallFunctionObjArgs(method, NULL);
        Py_DECREF(method);
    }

    /* Has a default value been given */
    if ((res == NULL) && (dflt != NULL) &&
        PyErr_ExceptionMatches(PyExc_TypeError))
    {
        PyErr_Clear();
        Py_INCREF(dflt);
        return dflt;
    }
    else if (res == NULL)
        return res;

    /* add gc_head size */
    if (PyObject_IS_GC(o)) {
        PyObject *tmp = res;
        res = PyNumber_Add(tmp, gc_head_size);
        Py_DECREF(tmp);
    }
    return res;
}

Here is the call graph for this function:

static PyObject* sys_gettrace ( PyObject self,
PyObject args 
) [static]

Definition at line 430 of file sysmodule.c.

{
    PyThreadState *tstate = PyThreadState_GET();
    PyObject *temp = tstate->c_traceobj;

    if (temp == NULL)
        temp = Py_None;
    Py_INCREF(temp);
    return temp;
}
static PyObject* sys_intern ( PyObject self,
PyObject args 
) [static]

Definition at line 275 of file sysmodule.c.

{
    PyObject *s;
    if (!PyArg_ParseTuple(args, "U:intern", &s))
        return NULL;
    if (PyUnicode_CheckExact(s)) {
        Py_INCREF(s);
        PyUnicode_InternInPlace(&s);
        return s;
    }
    else {
        PyErr_Format(PyExc_TypeError,
                        "can't intern %.400s", s->ob_type->tp_name);
        return NULL;
    }
}

Here is the call graph for this function:

static int sys_pyfile_write ( const char *  text,
PyObject file 
) [static]

Definition at line 1912 of file sysmodule.c.

{
    PyObject *unicode = NULL;
    int err;

    if (file == NULL)
        return -1;

    unicode = PyUnicode_FromString(text);
    if (unicode == NULL)
        return -1;

    err = sys_pyfile_write_unicode(unicode, file);
    Py_DECREF(unicode);
    return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int sys_pyfile_write_unicode ( PyObject unicode,
PyObject file 
) [static]

Definition at line 1878 of file sysmodule.c.

{
    PyObject *writer = NULL, *args = NULL, *result = NULL;
    int err;

    if (file == NULL)
        return -1;

    writer = PyObject_GetAttrString(file, "write");
    if (writer == NULL)
        goto error;

    args = PyTuple_Pack(1, unicode);
    if (args == NULL)
        goto error;

    result = PyEval_CallObject(writer, args);
    if (result == NULL) {
        goto error;
    } else {
        err = 0;
        goto finally;
    }

error:
    err = -1;
finally:
    Py_XDECREF(writer);
    Py_XDECREF(args);
    Py_XDECREF(result);
    return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* sys_setcheckinterval ( PyObject self,
PyObject args 
) [static]

Definition at line 490 of file sysmodule.c.

{
    if (PyErr_WarnEx(PyExc_DeprecationWarning,
                     "sys.getcheckinterval() and sys.setcheckinterval() "
                     "are deprecated.  Use sys.setswitchinterval() "
                     "instead.", 1) < 0)
        return NULL;
    if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval))
        return NULL;
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* sys_setprofile ( PyObject self,
PyObject args 
) [static]

Definition at line 449 of file sysmodule.c.

{
    if (trace_init() == -1)
        return NULL;
    if (args == Py_None)
        PyEval_SetProfile(NULL, NULL);
    else
        PyEval_SetProfile(profile_trampoline, args);
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* sys_setrecursionlimit ( PyObject self,
PyObject args 
) [static]

Definition at line 594 of file sysmodule.c.

{
    int new_limit;
    if (!PyArg_ParseTuple(args, "i:setrecursionlimit", &new_limit))
        return NULL;
    if (new_limit <= 0) {
        PyErr_SetString(PyExc_ValueError,
                        "recursion limit must be positive");
        return NULL;
    }
    Py_SetRecursionLimit(new_limit);
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* sys_settrace ( PyObject self,
PyObject args 
) [static]

Definition at line 410 of file sysmodule.c.

{
    if (trace_init() == -1)
        return NULL;
    if (args == Py_None)
        PyEval_SetTrace(NULL, NULL);
    else
        PyEval_SetTrace(trace_trampoline, args);
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static void sys_update_path ( int  argc,
wchar_t **  argv 
) [static]

Definition at line 1755 of file sysmodule.c.

{
    wchar_t *argv0;
    wchar_t *p = NULL;
    Py_ssize_t n = 0;
    PyObject *a;
    PyObject *path;
#ifdef HAVE_READLINK
    wchar_t link[MAXPATHLEN+1];
    wchar_t argv0copy[2*MAXPATHLEN+1];
    int nr = 0;
#endif
#if defined(HAVE_REALPATH)
    wchar_t fullpath[MAXPATHLEN];
#elif defined(MS_WINDOWS) && !defined(MS_WINCE)
    wchar_t fullpath[MAX_PATH];
#endif

    path = PySys_GetObject("path");
    if (path == NULL)
        return;

    argv0 = argv[0];

#ifdef HAVE_READLINK
    if (_HAVE_SCRIPT_ARGUMENT(argc, argv))
        nr = _Py_wreadlink(argv0, link, MAXPATHLEN);
    if (nr > 0) {
        /* It's a symlink */
        link[nr] = '\0';
        if (link[0] == SEP)
            argv0 = link; /* Link to absolute path */
        else if (wcschr(link, SEP) == NULL)
            ; /* Link without path */
        else {
            /* Must join(dirname(argv0), link) */
            wchar_t *q = wcsrchr(argv0, SEP);
            if (q == NULL)
                argv0 = link; /* argv0 without path */
            else {
                /* Must make a copy */
                wcscpy(argv0copy, argv0);
                q = wcsrchr(argv0copy, SEP);
                wcscpy(q+1, link);
                argv0 = argv0copy;
            }
        }
    }
#endif /* HAVE_READLINK */
#if SEP == '\\' /* Special case for MS filename syntax */
    if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) {
        wchar_t *q;
#if defined(MS_WINDOWS) && !defined(MS_WINCE)
        /* This code here replaces the first element in argv with the full
        path that it represents. Under CE, there are no relative paths so
        the argument must be the full path anyway. */
        wchar_t *ptemp;
        if (GetFullPathNameW(argv0,
                           sizeof(fullpath)/sizeof(fullpath[0]),
                           fullpath,
                           &ptemp)) {
            argv0 = fullpath;
        }
#endif
        p = wcsrchr(argv0, SEP);
        /* Test for alternate separator */
        q = wcsrchr(p ? p : argv0, '/');
        if (q != NULL)
            p = q;
        if (p != NULL) {
            n = p + 1 - argv0;
            if (n > 1 && p[-1] != ':')
                n--; /* Drop trailing separator */
        }
    }
#else /* All other filename syntaxes */
    if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) {
#if defined(HAVE_REALPATH)
        if (_Py_wrealpath(argv0, fullpath, PATH_MAX)) {
            argv0 = fullpath;
        }
#endif
        p = wcsrchr(argv0, SEP);
    }
    if (p != NULL) {
        n = p + 1 - argv0;
#if SEP == '/' /* Special case for Unix filename syntax */
        if (n > 1)
            n--; /* Drop trailing separator */
#endif /* Unix */
    }
#endif /* All others */
    a = PyUnicode_FromWideChar(argv0, n);
    if (a == NULL)
        Py_FatalError("no mem for sys.path insertion");
    if (PyList_Insert(path, 0, a) < 0)
        Py_FatalError("sys.path.insert(0) failed");
    Py_DECREF(a);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void sys_write ( char *  name,
FILE *  fp,
const char *  format,
va_list  va 
) [static]

Definition at line 1958 of file sysmodule.c.

{
    PyObject *file;
    PyObject *error_type, *error_value, *error_traceback;
    char buffer[1001];
    int written;

    PyErr_Fetch(&error_type, &error_value, &error_traceback);
    file = PySys_GetObject(name);
    written = PyOS_vsnprintf(buffer, sizeof(buffer), format, va);
    if (sys_pyfile_write(buffer, file) != 0) {
        PyErr_Clear();
        fputs(buffer, fp);
    }
    if (written < 0 || (size_t)written >= sizeof(buffer)) {
        const char *truncated = "... truncated";
        if (sys_pyfile_write(truncated, file) != 0)
            fputs(truncated, fp);
    }
    PyErr_Restore(error_type, error_value, error_traceback);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int trace_init ( void  ) [static]

Definition at line 308 of file sysmodule.c.

{
    static char *whatnames[7] = {"call", "exception", "line", "return",
                                    "c_call", "c_exception", "c_return"};
    PyObject *name;
    int i;
    for (i = 0; i < 7; ++i) {
        if (whatstrings[i] == NULL) {
            name = PyUnicode_InternFromString(whatnames[i]);
            if (name == NULL)
                return -1;
            whatstrings[i] = name;
        }
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int trace_trampoline ( PyObject self,
PyFrameObject frame,
int  what,
PyObject arg 
) [static]

Definition at line 377 of file sysmodule.c.

{
    PyThreadState *tstate = frame->f_tstate;
    PyObject *callback;
    PyObject *result;

    if (what == PyTrace_CALL)
        callback = self;
    else
        callback = frame->f_trace;
    if (callback == NULL)
        return 0;
    result = call_trampoline(tstate, callback, frame, what, arg);
    if (result == NULL) {
        PyEval_SetTrace(NULL, NULL);
        Py_XDECREF(frame->f_trace);
        frame->f_trace = NULL;
        return -1;
    }
    if (result != Py_None) {
        PyObject *temp = frame->f_trace;
        frame->f_trace = NULL;
        Py_XDECREF(temp);
        frame->f_trace = result;
    }
    else {
        Py_DECREF(result);
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int _check_interval = 100 [static]

Definition at line 487 of file sysmodule.c.

char branch[50] [static]

Definition at line 1311 of file sysmodule.c.

Initial value:
 {
    "sys.flags",        
    flags__doc__,       
    flags_fields,       



    12

}

Definition at line 1374 of file sysmodule.c.

Initial value:
 {
    {"debug",                   "-d"},
    {"division_warning",        "-Q"},
    {"inspect",                 "-i"},
    {"interactive",             "-i"},
    {"optimize",                "-O or -OO"},
    {"dont_write_bytecode",     "-B"},
    {"no_user_site",            "-s"},
    {"no_site",                 "-S"},
    {"ignore_environment",      "-E"},
    {"verbose",                 "-v"},



    
    
    {"bytes_warning",           "-b"},
    {"quiet",                   "-q"},
    {0}
}

Definition at line 1353 of file sysmodule.c.

Definition at line 1351 of file sysmodule.c.

Initial value:
 {
    "sys.hash_info",
    hash_info_doc,
    hash_info_fields,
    5,
}

Definition at line 627 of file sysmodule.c.

Initial value:
 {
    {"width", "width of the type used for hashing, in bits"},
    {"modulus", "prime number giving the modulus on which the hash "
                "function is based"},
    {"inf", "value to be used for hash of a positive infinity"},
    {"nan", "value to be used for hash of a nan"},
    {"imag", "multiplier used for the imaginary part of a complex number"},
    {NULL, NULL}
}

Definition at line 617 of file sysmodule.c.

Definition at line 609 of file sysmodule.c.

char patchlevel_revision[50] [static]

Definition at line 1310 of file sysmodule.c.

struct PyModuleDef [static]
Initial value:
 {
    PyModuleDef_HEAD_INIT,
    "sys",
    sys_doc,
    -1, 
    sys_methods,
    NULL,
    NULL,
    NULL,
    NULL
}

Definition at line 1492 of file sysmodule.c.

char shortbranch[50] [static]

Definition at line 1312 of file sysmodule.c.

int svn_initialized [static]

Definition at line 1309 of file sysmodule.c.

const char* svn_revision [static]

Definition at line 1313 of file sysmodule.c.

Definition at line 1023 of file sysmodule.c.

Initial value:
 {
    "sys.version_info",     
    version_info__doc__,    
    version_info_fields,    
    5
}

Definition at line 1439 of file sysmodule.c.

Initial value:
 {
    {"major", "Major release number"},
    {"minor", "Minor release number"},
    {"micro", "Patch release number"},
    {"releaselevel", "'alpha', 'beta', 'candidate', or 'release'"},
    {"serial", "Serial release number"},
    {0}
}

Definition at line 1430 of file sysmodule.c.

Definition at line 1428 of file sysmodule.c.

PyObject* warnoptions = NULL [static]

Definition at line 1123 of file sysmodule.c.

PyObject* whatstrings[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL} [static]

Definition at line 305 of file sysmodule.c.

PyObject* xoptions = NULL [static]

Definition at line 1162 of file sysmodule.c.