<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Hi,<div><br></div><div>I'm extending some old Visual Studio 6 code to add embedded python scripting. It works fine most of the time but some python function calls do not work as expected.</div>
<div><br></div><div>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)</div>
<div><br></div><div>Here's the error I'm getting:</div><div><br></div><div> Traceback (most recent call last):</div><div> File "...scripts\receipt_parser.py", line 296, in get_giftcard_purchase_value</div>
<div> details = extract_transaction_details_section(test)</div><div> File "...scripts\receipt_parser.py", line 204, in extract_transaction_details_section</div><div> for line in base_details:</div><div>TypeError: expected string or Unicode object, NoneType found</div>
<div><br></div><div>base_details is a list of strings (I can just define it like 'base_details=["1","2","3"...]' on the line previous) and the code runs fine when run from standard interpreter. Many other function calls work fine from the embedded app.</div>
<div><br></div><div>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</div>
<div><br></div><div>Anyone else had issues of this kind? My next try will be to use sub-interpreters per thread.</div><div><br></div><div>Thanks,</div><div>Paul.</div></span>