two embedded problem. one maybe is python bug.

yy x flingfly at gmail.com
Thu Aug 3 23:10:22 EDT 2006


hi,all,



the content of a.py :
#coding:gb2312
#/usr/local/bin/python
import random
print random.randint(0,10)

the c program:

#include <Python.h>
int main()
{
        Py_Initialize();
        PyRun_SimpleString("import sys");
        PyRun_SimpleString("sys.path.append('.')");

        PyRun_SimpleString("import a");
        Py_Finalize();

        return 0;
}

the gcc cmd line:

       g++ -o a a.c -I/usr/local/include/python /usr/local/lib/libpython -lm
-lpthread -ldl

First problem:

    when i run the a, the error msg is :

      Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "./a.py", line 1
SyntaxError: encoding problem: with BOM



but if i first import a.py through the python cmd line.  This problem
disappears.(but second problem appears)(now  I think  the a import a.pyc not
a.py)

I think  it's python bug, isn't it?

Second problem,

   Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "a.py", line 3, in ?
    import random
  File "/usr/local/lib/python2.4/random.py", line 44, in ?
    from math import log as _log, exp as _exp, pi as _pi, e as _e
ImportError: /usr/local/lib/python2.4/lib-dynload/math.so: undefined symbol:
PyExc_OverflowError.



Pls give me some advice, i am crazy.thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060804/5b13dcae/attachment.html>


More information about the Python-list mailing list