[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnubg] Re: Changes in gnubgmodule.c

From: Massimiliano Maini
Subject: [Bug-gnubg] Re: Changes in gnubgmodule.c
Date: Thu, 3 Sep 2009 14:36:15 +0200

Found the reason: exec('123') does not print out anything, while
enterrnig simply 123 at the python prompt does.

I guess that this:

extern void PythonRun(const char *sz)
        if (*sz) {
        } else {
                PyRun_SimpleString("import sys\n"
                                   "print 'Python', sys.version\n");
                while (PyRun_SimpleString(
                                   "while 1:\n"
                                   "    print '>>> ',\n"
                                   "    line = sys.stdin.readline()\n"
                                   "    if not line:\n"
                                   "        break\n"
                                   "    exec(line)\n"))

Should be changed to have the iteration over input lines in C
(but dunno if you can have readline functionalities as easily as in
python) and just call PyRun_SimpleString on each line.
Would also have to detect the ^Z to quit python mode ...


2009/9/3 Christian Anthon <address@hidden>:
> For reasons unknown it is not easy to start an interactive python
> session from within a python script so I cooked something quick that
> would at least partly emulate a session. Not too important I should
> think, but if it turns out that it works reliably with the official
> python we could improve on the session code.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]