Hi
I try to load python3.dll and python3XX.dll explicitly.
Wrapper works for functions but import variable as PyBool_Type seems to not work (or I miss something)
Here part of code
PyBool_Check(obj) returns always false
Did you try using the boolType pointer directly, rather than implicitly copying the PyTypeObject and referencing the copy? I wouldnât be surprised if Py_IS_TYPE is implemented in terms of the pointer address. (Also, I donât see a PyBool_FromLongPtr in the API, and youâre apparently passing a number, not a pointer. Shouldnât that be PyBool_FromLong?) (Also, since you have âNelsonâ in your username, I assume that Nelson::get_function is your own code in your own namespace. How should we be able to verify what it does?)
Yep, I agree, thatâs ugly. But since youâre not really working inside the same system anyway, itâs not really necessary to bind yourself to the same #define-based API. What you really want is to simply define PyBool_Check in a correct way for your situation. (Iâm a tad confused by PyBool_FromLongPtr, since that function doesnât exist, only PyBool_FromLong - thereâs no way that Iâm aware of to construct a bool from a pointer. Anyhow.) So Iâd be inclined to replace PyBool_Check with an actual inline function, or possibly just call PyObject_IsInstance directly (since thatâs part of the Stable ABI). If you really truly need the performance, an inline PyBool_Check that does a simple pointer comparison between Py_TYPE(obj) and the saved pointer to the bool type should suffice.