Skip to content

Commit

Permalink
C89 conformance for Python stable ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
wsfulton committed Mar 24, 2024
1 parent 9ab7d3b commit 8a68606
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 5 additions & 4 deletions Lib/python/pyhead.swg
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ SWIG_PyUnicode_AsUTF8AndSize(PyObject *str, Py_ssize_t *psize, PyObject **pbytes
*pbytes = NULL;
return PyUnicode_AsUTF8AndSize(str, psize);
# else
*pbytes = PyUnicode_AsUTF8String(str);
const char *chars = *pbytes ? PyBytes_AsString(*pbytes) : NULL;
if (chars && psize)
*psize = PyBytes_Size(*pbytes);
const char *chars;
*pbytes = PyUnicode_AsUTF8String(str);
chars = *pbytes ? PyBytes_AsString(*pbytes) : NULL;
if (chars && psize)
*psize = PyBytes_Size(*pbytes);
return chars;
# endif
#else
Expand Down
14 changes: 10 additions & 4 deletions Lib/python/pyrun.swg
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,14 @@ SwigPyObject_Check(PyObject *op) {
return 1;
return (strcmp(op_type->tp_name, "SwigPyObject") == 0);
#else
# ifdef Py_LIMITED_API
int cmp;
PyObject *tp_name;
#endif
if (op_type == target_tp)
return 1;
# ifdef Py_LIMITED_API
int cmp;
PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
if (!tp_name)
return 0;
cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyObject");
Expand Down Expand Up @@ -1132,12 +1135,15 @@ SwigPyPacked_type(void) {

SWIGRUNTIMEINLINE int
SwigPyPacked_Check(PyObject *op) {
#ifdef Py_LIMITED_API
int cmp;
PyObject *tp_name;
#endif
PyTypeObject* op_type = Py_TYPE(op);
if (op_type == SwigPyPacked_TypeOnce())
return 1;
#ifdef Py_LIMITED_API
int cmp;
PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
if (!tp_name)
return 0;
cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyPacked");
Expand Down

0 comments on commit 8a68606

Please sign in to comment.