Skip to content

Commit 7f85243

Browse files
committed
fix and test that PyLong_Check is true for bools
1 parent 9b582a4 commit 7f85243

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

graalpython/com.oracle.graal.python.cext/src/boolobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#include <stdarg.h>
4444

45-
PyTypeObject PyBool_Type = PY_TRUFFLE_TYPE("bool", &PyType_Type, Py_TPFLAGS_DEFAULT, sizeof(struct _longobject));
45+
PyTypeObject PyBool_Type = PY_TRUFFLE_TYPE("bool", &PyType_Type, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_LONG_SUBCLASS, sizeof(struct _longobject));
4646

4747
// taken from CPython "Python/Objects/boolobject.c"
4848
PyObject *PyBool_FromLong(long ok) {

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_abstract.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@ def compile_module(self, name):
240240
cmpfunc=unhandled_error_compare
241241
)
242242

243+
test_PyLong_Check = CPyExtFunction(
244+
lambda args: isinstance(args[0], int),
245+
_default_unarop_args,
246+
resultspec="i",
247+
argspec='O',
248+
arguments=["PyObject* v"],
249+
cmpfunc=unhandled_error_compare
250+
)
251+
243252
test_PyNumber_Add = CPyExtFunction(
244253
lambda args: args[0] + args[1],
245254
lambda: (

0 commit comments

Comments
 (0)