Skip to content

Commit 6d13f94

Browse files
mascisbinet
authored andcommitted
fix PyDict_Next, C function actually returns bool
1 parent ba7e583 commit 6d13f94

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

dict.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package python
44
import "C"
55

66
import (
7-
"errors"
87
"unsafe"
98
)
109

@@ -160,9 +159,9 @@ func PyDict_Size(self *PyObject) int {
160159
// Py_DECREF(o);
161160
// }
162161
// Changed in version 2.5: This function used an int * type for ppos. This might require changes in your code for properly supporting 64-bit systems.
163-
func PyDict_Next(self *PyObject, pos *int, key, value **PyObject) error {
162+
func PyDict_Next(self *PyObject, pos *int, key, value **PyObject) bool {
164163
if pos == nil {
165-
return errors.New("invalid position")
164+
return false
166165
}
167166

168167
c_pos := C.Py_ssize_t(*pos)
@@ -175,7 +174,7 @@ func PyDict_Next(self *PyObject, pos *int, key, value **PyObject) error {
175174
*key = togo(c_key)
176175
*value = togo(c_val)
177176

178-
return int2err(err)
177+
return int2bool(err)
179178
}
180179

181180
// int PyDict_Merge(PyObject *a, PyObject *b, int override)

object.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func int2err(i C.int) error {
8383
return nil
8484
}
8585
//FIXME: also handle python exceptions ?
86-
return &gopy_err{fmt.Sprintf("error in C-Python (rc=%i)", int(i))}
86+
return &gopy_err{fmt.Sprintf("error in C-Python (rc=%d)", int(i))}
8787
}
8888

8989
func file2go(f *C.FILE) *os.File {

0 commit comments

Comments
 (0)