Python Forum
Python Extensions with C Custom PyObject?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Extensions with C Custom PyObject?
#7
(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
Reply


Messages In This Thread
RE: Python Extensions with C Custom PyObject? - by babaliaris - Feb-14-2018, 11:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I want to create custom charts in Python. js1152410 1 585 Nov-13-2023, 05:45 PM
Last Post: gulshan212
  importing same python library in multiple custom module escape_freedom13 6 3,906 May-10-2020, 07:01 PM
Last Post: escape_freedom13
  Importing Custom Modules in Python 3 Flexico 1 2,625 Aug-24-2019, 08:11 PM
Last Post: snippsat
  problem using custom exception handling in python srm 3 3,103 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  Detecting file extensions ellipsis 1 2,335 Nov-15-2018, 07:44 AM
Last Post: buran
  Chrome Extensions austinr 0 2,240 Sep-21-2018, 05:22 AM
Last Post: austinr
  How to convert c_void_p PyObject back to void* lfdm 0 3,948 Feb-02-2017, 09:13 AM
Last Post: lfdm
  Custom widget in Python-Qt, 'live' at Qt Designer panoss 3 5,735 Jan-05-2017, 11:47 AM
Last Post: panoss

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020