Feb-14-2018, 11:20 AM
(Feb-13-2018, 09:00 PM)Gribouillis Wrote: AFAIK PyArg_ParseTuple does not incref the item, but you don't need to incref it yourself, because there is already a reference on the item in the argument tuple. If you don't incref it, you must not decref it upon leaving the function. If your code calls List_Append, it will probably keep a reference to the item, which means that List_Append needs to incref the item one way or another.
I found a <document> that may help you.
About the assert question, can you elaborate on the issue, because I run your code and I get
Output:Traceback (most recent call last): File "asserttruc.py", line 7, in <module> run_test( unit_test ) File "asserttruc.py", line 5, in run_test func() File "asserttruc.py", line 2, in unit_test assert(False) AssertionError
I want assert to do what it does without raising an exception.
Well i found this and it works.
import inspect def ASSERT(condition): if (condition == False): callerframerecord = inspect.stack()[1] frame = callerframerecord[0] info = inspect.getframeinfo(frame) print("Assertion Failed:\n") print ("In file : "+info.filename) print ("In function: "+info.function) print ("At line : "+str(info.lineno)) def unit_test(): ASSERT(False) def run_test(func): func() run_test( unit_test )
Assertion Failed: In file : C:\Users\babaliaris\Desktop\a.py In function: unit_test At line : 16