Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 7827a2c

Browse files
committed
Merge pull request #20 from sbinet/pr-19
cosmetics for PR #19
2 parents 1967380 + 873aabc commit 7827a2c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

otherobjects.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,4 +592,19 @@ func PyCallIter_New(callable, sentinel *PyObject) *PyObject {
592592
return togo(C.PyCallIter_New(topy(callable), topy(sentinel)))
593593
}
594594

595+
// PyCodeObject* PyCode_NewEmpty(char *filename, char *funcname, int firstlineno)
596+
// Return value: New reference.
597+
// Return an empty CodePythonObject that corresponds to the file name, func name and line number in the source file it points to.
598+
func PyCode_NewEmpty(filename string, funcname string, firstlineno int) *PyObject {
599+
c_filename := C.CString(filename)
600+
defer C.free(unsafe.Pointer(c_filename))
601+
c_funcname := C.CString(funcname)
602+
defer C.free(unsafe.Pointer(c_funcname))
603+
604+
o := C.PyCode_NewEmpty(c_filename, c_funcname, C.int(firstlineno))
605+
606+
// need to (unsafe-ly) cast to *C.PyObject as o is a *C.PyCodeObject
607+
return togo((*C.PyObject)(unsafe.Pointer(o)))
608+
}
609+
595610
// EOF

0 commit comments

Comments
 (0)