On Mon, Apr 1, 2013 at 12:57 PM, Chris Nighswonger <
[email protected]> wrote:
> However, this code borks:
>
> use Inline Python => 'DATA',
> DIRECTORY => '/usr/share/webmin/pykota/.Inline/',
> NAME => 'PyKota::Test';
>
> print pykota_version();
> 1;
>
> __DATA__
>
> __Python__
>
> def pykota_version():
> from pykota.version import __version__
> return __version__
>
>
> The error is:
>
> File "<string>", line 3
> from pykota.version import
> ^
> SyntaxError: invalid syntax
> Error -- py_eval raised an exception at
> /usr/local/lib/perl/5.14.2/Inline/Python.pm line 177.
> INIT failed--call queue aborted.
>
So I threw together some C to see if the problem was with my Python syntax
in the context of Inline::Python. Below is what I did and it works as
expected.
Any suggestions as to where I'm going wrong here?
Kind Regards,
Chris
#include <Python.h>
main( ) {
PyObject *pstr, *pmod, *pdict;
Py_Initialize( );
pmod = PyImport_ImportModule("__main__");
pdict = PyModule_GetDict(pmod);
pstr = PyRun_String(
"def pykota_version():\n"
" from pykota.version import __version__\n"
" return __version__\n"
"print pykota_version()\n"
, Py_file_input, pdict, pdict);
if (!pstr) {
PyErr_Print();
exit (1);
}
Py_DECREF(pmod);
Py_DECREF(pstr);
}