Skip to content

Commit df45d6b

Browse files
Convert PyBytes_Check macro to a function
1 parent 2f6b380 commit df45d6b

6 files changed

Lines changed: 32 additions & 17 deletions

File tree

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/boolobject.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ extern "C" {
99

1010
// PyBool_Type is declared by object.h
1111

12-
#define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
12+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03100000
13+
PyAPI_FUNC(int) PyBool_Check(PyObject *x);
14+
#endif
15+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x03100000
16+
# define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
17+
#endif
1318

1419
/* Py_False and Py_True are the only two bools in existence. */
1520

Lib/test/test_stable_abi_ctypes.py

Lines changed: 13 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Misc/stable_abi.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,3 +2831,6 @@
28312831

28322832
[function.PyObject_CallFinalizerFromDealloc]
28332833
added = '3.15'
2834+
2835+
[function.PyBool_Check]
2836+
added = '3.16'

Objects/boolobject.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ PyObject *PyBool_FromLong(long ok)
2323
return ok ? Py_True : Py_False;
2424
}
2525

26+
#undef PyBool_Check
27+
28+
int
29+
PyBool_Check(PyObject *x)
30+
{
31+
return Py_IS_TYPE(x, &PyBool_Type);
32+
}
33+
2634
/* We define bool_new to always return either Py_True or Py_False */
2735

2836
static PyObject *

PC/python3dll.c

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)