pass bool values to the Python function in embedded python 3.0

Discussion in 'Python' started by BigHand, Mar 7, 2009.

  1. BigHand

    BigHand Guest

    Guys, How do I transfer the parameters ?
    in python code:
    traceback.format_exception(exc_type, exc_val, exc_tb, 2, True)

    in C++ code:
    obFunc_format_exception = PyObject_GetAttrString(modTB,
    "format_exception");
    tbArgs = Py_BuildValue("OOOii", exc_type, exc_value, exc_tb, 2, 1);
    tbResultList = PyObject_CallObject(obFunc_format_exception , tbArgs);

    how do I pass True to the Python function in the C++ code?
    BigHand, Mar 7, 2009
    #1
    1. Advertising

  2. BigHand

    BigHand Guest

    On Mar 7, 5:38 pm, BigHand <> wrote:
    > Guys, How do I transfer the parameters ?
    > in python code:
    > traceback.format_exception(exc_type, exc_val, exc_tb, 2, True)
    >
    > in C++ code:
    > obFunc_format_exception = PyObject_GetAttrString(modTB,
    > "format_exception");
    > tbArgs = Py_BuildValue("OOOii", exc_type, exc_value, exc_tb, 2, 1);
    > tbResultList = PyObject_CallObject(obFunc_format_exception , tbArgs);
    >
    > how do I pass True to the Python function in the C++ code?

    build the python object
    tbArgs = Py_BuildValue("OOOOO", exc_type, exc_value, exc_tb, Py_None,
    Py_True);
    tbResultList = PyObject_CallObject(obFunc_format_exception , tbArgs);
    but I can't get the format_exception called successfully.
    could anyone help me ?
    BigHand, Mar 7, 2009
    #2
    1. Advertising

  3. En Sat, 07 Mar 2009 07:38:29 -0200, BigHand <> escribió:

    > how do I pass True to the Python function in the C++ code?


    (I've already suggested using PyErr_Print/PyTraceback_Print instead)

    See the section "Boolean Objects" in the C API Reference:

    "PyObject* Py_True
    The Python True object. This object has no methods. It needs to be treated
    just like any other object with respect to reference counts."

    --
    Gabriel Genellina
    Gabriel Genellina, Mar 7, 2009
    #3
  4. BigHand

    BigHand Guest

    On 3月7æ—¥, 下åˆ10æ—¶38分, "Gabriel Genellina" <> wrote:
    > En Sat, 07 Mar 2009 07:38:29 -0200, BigHand <> escribió:
    >
    > > how do I pass True to the Python function in the C++ code?

    >
    > (I've already suggested using PyErr_Print/PyTraceback_Print instead)
    >
    > See the section "Boolean Objects" in the C API Reference:
    >
    > "PyObject* Py_True
    > The Python True object. This object has no methods. It needs to be treated  
    > just like any other object with respect to reference counts."
    >
    > --
    > Gabriel Genellina


    tbArgs = Py_BuildValue("OOOOO", exc_type, exc_value, exc_tb,
    Py_None,
    Py_True);
    tbResultList = PyObject_CallObject(obFunc_format_exception , tbArgs);

    should increase the ref count of Py_True first?
    this can't call the python function format_exception successfully
    either.

    B.R.
    BH
    BigHand, Mar 7, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dongsheng Ruan
    Replies:
    1
    Views:
    420
    Gabriel Genellina
    Jan 19, 2007
  2. deanfamily
    Replies:
    4
    Views:
    403
    puzzlecracker
    Oct 24, 2005
  3. Rui Maciel
    Replies:
    2
    Views:
    1,591
    Rui Maciel
    Dec 1, 2009
  4. Abhishek Padmanabh
    Replies:
    1
    Views:
    364
    Bo Persson
    Mar 21, 2011
  5. Baohua Li

    Pass bool parameter to web method

    Baohua Li, Jan 16, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    432
    Jan Tielens
    Jan 20, 2004
Loading...

Share This Page