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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy