We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bd44a9e commit f976f61Copy full SHA for f976f61
file.go
@@ -17,12 +17,17 @@ import "C"
17
18
import (
19
"os"
20
+ "unsafe"
21
)
22
23
// FromFile converts a Go file to Python file object.
24
// Calling close from Python will not close a file descriptor.
25
func FromFile(f *os.File, mode string) *PyObject {
- p := C._gopy_PyFile_FromFile(C.int(f.Fd()), C.CString(f.Name()), C.CString(mode))
26
+ cname := C.CString(f.Name())
27
+ cmode := C.CString(mode)
28
+ p := C._gopy_PyFile_FromFile(C.int(f.Fd()), cname, cmode)
29
+ C.free(unsafe.Pointer(cname))
30
+ C.free(unsafe.Pointer(cmode))
31
return togo(p)
32
}
33
0 commit comments