Skip to content

Commit 8a68606

Browse files
committed
C89 conformance for Python stable ABI
1 parent 9ab7d3b commit 8a68606

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Lib/python/pyhead.swg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ SWIG_PyUnicode_AsUTF8AndSize(PyObject *str, Py_ssize_t *psize, PyObject **pbytes
3535
*pbytes = NULL;
3636
return PyUnicode_AsUTF8AndSize(str, psize);
3737
# else
38-
*pbytes = PyUnicode_AsUTF8String(str);
39-
const char *chars = *pbytes ? PyBytes_AsString(*pbytes) : NULL;
40-
if (chars && psize)
41-
*psize = PyBytes_Size(*pbytes);
38+
const char *chars;
39+
*pbytes = PyUnicode_AsUTF8String(str);
40+
chars = *pbytes ? PyBytes_AsString(*pbytes) : NULL;
41+
if (chars && psize)
42+
*psize = PyBytes_Size(*pbytes);
4243
return chars;
4344
# endif
4445
#else

Lib/python/pyrun.swg

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,14 @@ SwigPyObject_Check(PyObject *op) {
745745
return 1;
746746
return (strcmp(op_type->tp_name, "SwigPyObject") == 0);
747747
#else
748+
# ifdef Py_LIMITED_API
749+
int cmp;
750+
PyObject *tp_name;
751+
#endif
748752
if (op_type == target_tp)
749753
return 1;
750754
# ifdef Py_LIMITED_API
751-
int cmp;
752-
PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
755+
tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
753756
if (!tp_name)
754757
return 0;
755758
cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyObject");
@@ -1132,12 +1135,15 @@ SwigPyPacked_type(void) {
11321135

11331136
SWIGRUNTIMEINLINE int
11341137
SwigPyPacked_Check(PyObject *op) {
1138+
#ifdef Py_LIMITED_API
1139+
int cmp;
1140+
PyObject *tp_name;
1141+
#endif
11351142
PyTypeObject* op_type = Py_TYPE(op);
11361143
if (op_type == SwigPyPacked_TypeOnce())
11371144
return 1;
11381145
#ifdef Py_LIMITED_API
1139-
int cmp;
1140-
PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
1146+
tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__");
11411147
if (!tp_name)
11421148
return 0;
11431149
cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyPacked");

0 commit comments

Comments
 (0)