Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

Location:
python/vendor/current/Demo/embed
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Demo/embed/Makefile

    r2 r388  
    11# Makefile for embedded Python use demo.
    2 # (This version tailored for my Red Hat Linux 6.1 setup;
     2# (This version originally written on Red Hat Linux 6.1;
    33# edit lines marked with XXX.)
    44
     
    1111
    1212# Python version
    13 VERSION=        2.6
     13VERSION=        2.7
    1414
    1515# Compiler flags
     
    2222LIBPYTHON=      $(blddir)/libpython$(VERSION).a
    2323
    24 # XXX edit LIBS (in particular) to match $(blddir)/Modules/Makefile
     24# XXX edit LIBS (in particular) to match $(blddir)/Makefile
    2525LIBS=           -lnsl -ldl -lreadline -ltermcap -lieee -lpthread -lutil
    2626LDFLAGS=        -Xlinker -export-dynamic
  • python/vendor/current/Demo/embed/demo.c

    r2 r388  
    77main(int argc, char **argv)
    88{
    9         /* Pass argv[0] to the Python interpreter */
    10         Py_SetProgramName(argv[0]);
     9    /* Pass argv[0] to the Python interpreter */
     10    Py_SetProgramName(argv[0]);
    1111
    12         /* Initialize the Python interpreter.  Required. */
    13         Py_Initialize();
     12    /* Initialize the Python interpreter.  Required. */
     13    Py_Initialize();
    1414
    15         /* Add a static module */
    16         initxyzzy();
     15    /* Add a static module */
     16    initxyzzy();
    1717
    18         /* Define sys.argv.  It is up to the application if you
    19            want this; you can also let it undefined (since the Python
    20            code is generally not a main program it has no business
    21            touching sys.argv...) */
    22         PySys_SetArgv(argc, argv);
     18    /* Define sys.argv.  It is up to the application if you
     19       want this; you can also leave it undefined (since the Python
     20       code is generally not a main program it has no business
     21       touching sys.argv...)
    2322
    24         /* Do some application specific code */
    25         printf("Hello, brave new world\n\n");
     23       If the third argument is true, sys.path is modified to include
     24       either the directory containing the script named by argv[0], or
     25       the current working directory.  This can be risky; if you run
     26       an application embedding Python in a directory controlled by
     27       someone else, attackers could put a Trojan-horse module in the
     28       directory (say, a file named os.py) that your application would
     29       then import and run.
     30    */
     31    PySys_SetArgvEx(argc, argv, 0);
    2632
    27         /* Execute some Python statements (in module __main__) */
    28         PyRun_SimpleString("import sys\n");
    29         PyRun_SimpleString("print sys.builtin_module_names\n");
    30         PyRun_SimpleString("print sys.modules.keys()\n");
    31         PyRun_SimpleString("print sys.executable\n");
    32         PyRun_SimpleString("print sys.argv\n");
     33    /* Do some application specific code */
     34    printf("Hello, brave new world\n\n");
    3335
    34         /* Note that you can call any public function of the Python
    35            interpreter here, e.g. call_object(). */
     36    /* Execute some Python statements (in module __main__) */
     37    PyRun_SimpleString("import sys\n");
     38    PyRun_SimpleString("print sys.builtin_module_names\n");
     39    PyRun_SimpleString("print sys.modules.keys()\n");
     40    PyRun_SimpleString("print sys.executable\n");
     41    PyRun_SimpleString("print sys.argv\n");
    3642
    37         /* Some more application specific code */
    38         printf("\nGoodbye, cruel world\n");
     43    /* Note that you can call any public function of the Python
     44       interpreter here, e.g. call_object(). */
    3945
    40         /* Exit, cleaning up the interpreter */
    41         Py_Exit(0);
    42         /*NOTREACHED*/
     46    /* Some more application specific code */
     47    printf("\nGoodbye, cruel world\n");
     48
     49    /* Exit, cleaning up the interpreter */
     50    Py_Exit(0);
     51    /*NOTREACHED*/
    4352}
    4453
     
    4958xyzzy_foo(PyObject *self, PyObject* args)
    5059{
    51         return PyInt_FromLong(42L);
     60    return PyInt_FromLong(42L);
    5261}
    5362
    5463static PyMethodDef xyzzy_methods[] = {
    55         {"foo",         xyzzy_foo,      METH_NOARGS,
    56         "Return the meaning of everything."},
    57         {NULL,          NULL}           /* sentinel */
     64    {"foo",             xyzzy_foo,      METH_NOARGS,
     65    "Return the meaning of everything."},
     66    {NULL,              NULL}           /* sentinel */
    5867};
    5968
     
    6170initxyzzy(void)
    6271{
    63         PyImport_AddModule("xyzzy");
    64         Py_InitModule("xyzzy", xyzzy_methods);
     72    PyImport_AddModule("xyzzy");
     73    Py_InitModule("xyzzy", xyzzy_methods);
    6574}
  • python/vendor/current/Demo/embed/loop.c

    r2 r388  
    77main(int argc, char **argv)
    88{
    9         int count = -1;
    10         char *command;
     9    int count = -1;
     10    char *command;
    1111
    12         if (argc < 2 || argc > 3) {
    13                 fprintf(stderr, "usage: loop <python-command> [count]\n");
    14                 exit(2);
    15         }
    16         command = argv[1];
     12    if (argc < 2 || argc > 3) {
     13        fprintf(stderr, "usage: loop <python-command> [count]\n");
     14        exit(2);
     15    }
     16    command = argv[1];
    1717
    18         if (argc == 3) {
    19                 count = atoi(argv[2]);
    20         }
     18    if (argc == 3) {
     19        count = atoi(argv[2]);
     20    }
    2121
    22         Py_SetProgramName(argv[0]);
     22    Py_SetProgramName(argv[0]);
    2323
    24         /* uncomment this if you don't want to load site.py */
    25         /* Py_NoSiteFlag = 1; */
     24    /* uncomment this if you don't want to load site.py */
     25    /* Py_NoSiteFlag = 1; */
    2626
    27         while (count == -1 || --count >= 0 ) {
    28                 Py_Initialize();
    29                 PyRun_SimpleString(command);
    30                 Py_Finalize();
    31         }
    32         return 0;
     27    while (count == -1 || --count >= 0 ) {
     28        Py_Initialize();
     29        PyRun_SimpleString(command);
     30        Py_Finalize();
     31    }
     32    return 0;
    3333}
Note: See TracChangeset for help on using the changeset viewer.