Back to index

python3.2  3.2.2
python.c File Reference
#include "Python.h"
#include <locale.h>

Go to the source code of this file.


int main (int argc, char **argv)

Function Documentation

int main ( int argc  ,
char **  argv 

Definition at line 23 of file python.c.

    wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*argc);
    /* We need a second copies, as Python might modify the first one. */
    wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*argc);
    int i, res;
    char *oldloc;
    /* 754 requires that FP exceptions run in "no stop" mode by default,
     * and until C vendors implement C99's ways to control FP exceptions,
     * Python requires non-stop mode.  Alas, some platforms enable FP
     * exceptions by default.  Here we disable them.
#ifdef __FreeBSD__
    fp_except_t m;

    m = fpgetmask();
    fpsetmask(m & ~FP_X_OFL);
    if (!argv_copy || !argv_copy2) {
        fprintf(stderr, "out of memory\n");
        return 1;
    oldloc = strdup(setlocale(LC_ALL, NULL));
    setlocale(LC_ALL, "");
    for (i = 0; i < argc; i++) {
#ifdef __APPLE__
        argv_copy[i] = _Py_DecodeUTF8_surrogateescape(argv[i], strlen(argv[i]));
        argv_copy[i] = _Py_char2wchar(argv[i], NULL);
        if (!argv_copy[i])
            return 1;
        argv_copy2[i] = argv_copy[i];
    setlocale(LC_ALL, oldloc);
    res = Py_Main(argc, argv_copy);
    for (i = 0; i < argc; i++) {
    return res;

Here is the call graph for this function: