Skip to content

Commit e4de5b1

Browse files
authored
Merge pull request #102 from kou/clear-error
Clear error from rb_protect to ignore error
2 parents fc76c0b + 5e80cb2 commit e4de5b1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ext/pycall/libpython.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ lookup_libpython_api(VALUE libpython_handle, char const *name)
3030
arg.libpython_handle = libpython_handle;
3131
arg.name = name;
3232
addr = rb_protect((VALUE (*)(VALUE))lookup_libpython_api_0, (VALUE)&arg, &state);
33-
return (state || NIL_P(addr)) ? NULL : NUM2PTR(addr);
33+
if (state) {
34+
rb_set_errinfo(Qnil);
35+
return NULL;
36+
}
37+
else {
38+
return NIL_P(addr) ? NULL : NUM2PTR(addr);
39+
}
3440
}
3541

3642
#define LOOKUP_API_ENTRY(api_name) lookup_libpython_api(libpython_handle, #api_name)

0 commit comments

Comments
 (0)