FAQ
Hi,

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
get_giftcard_purchase_value
details = extract_transaction_details_section(test)
File "...scripts\receipt_parser.py", line 204, in
extract_transaction_details_section
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
app.

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?

Thanks,
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100202/7c696d48/attachment.htm>

Search Discussions

  • Paul Atkin at Feb 1, 2010 at 11:51 am
    Hi,

    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
    get_giftcard_purchase_value
    details = extract_transaction_details_section(test)
    File "...scripts\receipt_parser.py", line 204, in
    extract_transaction_details_section
    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
    app.

    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?

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 1, '10 at 11:36a
activeFeb 1, '10 at 11:51a
posts2
users1
websitepython.org

1 user in discussion

Paul Atkin: 2 posts

People

Translate

site design / logo © 2022 Grokbase