Embedded python 2.6 in C++ problems

Paul Atkin gobladoome at gmail.com
Mon Feb 1 12:51:48 CET 2010


I'm extending some old Visual Studio 6 MFC code to add embedded python
scripting. It works fine most of the time but some python function calls do
not work as expected.

The C++ code is a multithreaded MFC application. I was assuming that it was
GIL issues but I have tried using the manual locking (PyEval_SaveThread &
PyEval_RestoreThread) and what seems to be the current method
(PyGILState_Ensure & PyGILState_Release)

Here's the error I'm getting:

 Traceback (most recent call last):
  File "...scripts\receipt_parser.py", line 296, in
    details = extract_transaction_details_section(test)
  File "...scripts\receipt_parser.py", line 204, in
    for line in base_details:
TypeError: expected string or Unicode object, NoneType found

base_details is a string variable and the code runs fine when run from
standard interpreter. Many other function calls work fine from the embedded

I create and then Py_DECREF the function parameters and the return value
after each function call. The module import is created at C++ object
constructor and then Py_DECREF'd in the desctuctor

Anyone else had issues of this kind?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100202/2b286e97/attachment.html>

More information about the Python-list mailing list