Skip to content

Commit 3e2f35d

Browse files
committed
finish switching to non-macro versions of Python APIs,
and adding wxPy APIs for things not supported by Py_LIMITED_API
1 parent a5a777e commit 3e2f35d

File tree

13 files changed

+44
-27
lines changed

13 files changed

+44
-27
lines changed

etg/cmndata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def run():
8383
return;
8484
}
8585
86-
self->SetPrivData(PyBytes_AS_STRING(data), PyBytes_GET_SIZE(data));
86+
self->SetPrivData(PyBytes_AsString(data), PyBytes_Size(data));
8787
""")
8888

8989
c.addAutoProperties()

etg/dataview.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ def _fixupBoolGetters(method, sig):
417417
col_obj = Py_None;
418418
Py_INCREF(Py_None);
419419
}
420-
PyTuple_SET_ITEM(value, 0, item_obj);
421-
PyTuple_SET_ITEM(value, 1, col_obj);
420+
PyTuple_SetItem(value, 0, item_obj);
421+
PyTuple_SetItem(value, 1, col_obj);
422422
// PyTuple steals a reference, so we don't need to decref the items here
423423
return value;
424424
""")

etg/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def run():
513513
}
514514
for (int i=0; i<count; i++) {
515515
PyObject* s = wx2PyString(files[i]);
516-
PyList_SET_ITEM(list, i, s);
516+
PyList_SetItem(list, i, s);
517517
}
518518
return list;
519519
""")

etg/palette.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def run():
6060
unsigned char* blueArray = new unsigned char[count];
6161
6262
for (Py_ssize_t i = 0; i < count; i++) {
63-
PyObject* redItem = PySequence_ITEM(red, i);
64-
PyObject* greenItem = PySequence_ITEM(green, i);
65-
PyObject* blueItem = PySequence_ITEM(blue, i);
63+
PyObject* redItem = PySequence_GetItem(red, i);
64+
PyObject* greenItem = PySequence_GetItem(green, i);
65+
PyObject* blueItem = PySequence_GetItem(blue, i);
6666
if (!wxPyInt_Check(redItem) || !wxPyInt_Check(greenItem) || !wxPyInt_Check(blueItem)) {
6767
PyErr_SetString(PyExc_TypeError, errMsg);
6868
goto pch_exit;

etg/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def run():
274274
PyErr_SetString(PyExc_TypeError, "Bytes object expected");
275275
return NULL;
276276
}
277-
self->Write(PyBytes_AS_STRING(data), PyBytes_GET_SIZE(data));
277+
self->Write(PyBytes_AsString(data), PyBytes_Size(data));
278278
RETURN_NONE();
279279
""")
280280

etg/treelist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def run():
9696
for (size_t i=0; i<count; i++) {
9797
wxTreeListItem* item = new wxTreeListItem(items[i]);
9898
PyObject* obj = wxPyConstructObject((void*)item, wxT("wxTreeListItem"), true);
99-
PyList_SET_ITEM(list, i, obj); // PyList_SET_ITEM steals a reference
99+
PyList_SetItem(list, i, obj); // steals a reference
100100
}
101101
return list;
102102
""")

src/event_ex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void wxPyCallback::EventThunker(wxEvent& event) {
4949
} else {
5050
// Call the event handler, passing the event object
5151
tuple = PyTuple_New(1);
52-
PyTuple_SET_ITEM(tuple, 0, arg); // steals ref to arg
52+
PyTuple_SetItem(tuple, 0, arg); // steals ref to arg
5353
result = PyEval_CallObject(func, tuple);
5454
if ( result ) {
5555
Py_DECREF(result); // result is ignored, but we still need to decref it

src/stream_input.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ static PyObject* wxPyGetMethod(PyObject* py, char* name)
55
if (!PyObject_HasAttrString(py, name))
66
return NULL;
77
PyObject* o = PyObject_GetAttrString(py, name);
8-
if (!PyMethod_Check(o) && !PyCFunction_Check(o)) {
8+
if (!wxPyMethod_Check(o) && !PyCFunction_Check(o)) {
99
Py_DECREF(o);
1010
return NULL;
1111
}
@@ -116,11 +116,11 @@ class wxPyInputStream : public wxInputStream
116116

117117
if (sizeof(wxFileOffset) > sizeof(long))
118118
// wxFileOffset is a 64-bit value...
119-
PyTuple_SET_ITEM(arglist, 0, PyLong_FromLongLong(off));
119+
PyTuple_SetItem(arglist, 0, PyLong_FromLongLong(off));
120120
else
121-
PyTuple_SET_ITEM(arglist, 0, wxPyInt_FromLong(off));
121+
PyTuple_SetItem(arglist, 0, wxPyInt_FromLong(off));
122122

123-
PyTuple_SET_ITEM(arglist, 1, wxPyInt_FromLong(mode));
123+
PyTuple_SetItem(arglist, 1, wxPyInt_FromLong(mode));
124124

125125

126126
PyObject* result = PyEval_CallObject(m_seek, arglist);

src/stream_output.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ static PyObject* wxPyGetMethod(PyObject* py, char* name)
55
if (!PyObject_HasAttrString(py, name))
66
return NULL;
77
PyObject* o = PyObject_GetAttrString(py, name);
8-
if (!PyMethod_Check(o) && !PyCFunction_Check(o)) {
8+
if (!wxPyMethod_Check(o) && !PyCFunction_Check(o)) {
99
Py_DECREF(o);
1010
return NULL;
1111
}
@@ -90,7 +90,7 @@ class wxPyOutputStream : public wxOutputStream
9090

9191
wxPyThreadBlocker blocker;
9292
PyObject* arglist = PyTuple_New(1);
93-
PyTuple_SET_ITEM(arglist, 0, PyBytes_FromStringAndSize((char*)buffer, bufsize));
93+
PyTuple_SetItem(arglist, 0, PyBytes_FromStringAndSize((char*)buffer, bufsize));
9494

9595
PyObject* result = PyEval_CallObject(m_write, arglist);
9696
Py_DECREF(arglist);
@@ -109,11 +109,11 @@ class wxPyOutputStream : public wxOutputStream
109109

110110
if (sizeof(wxFileOffset) > sizeof(long))
111111
// wxFileOffset is a 64-bit value...
112-
PyTuple_SET_ITEM(arglist, 0, PyLong_FromLongLong(off));
112+
PyTuple_SetItem(arglist, 0, PyLong_FromLongLong(off));
113113
else
114-
PyTuple_SET_ITEM(arglist, 0, wxPyInt_FromLong(off));
114+
PyTuple_SetItem(arglist, 0, wxPyInt_FromLong(off));
115115

116-
PyTuple_SET_ITEM(arglist, 1, wxPyInt_FromLong(mode));
116+
PyTuple_SetItem(arglist, 1, wxPyInt_FromLong(mode));
117117

118118

119119
PyObject* result = PyEval_CallObject(m_seek, arglist);

src/string.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
%ConvertToTypeCode
2626
#if wxUSE_UNICODE_WCHAR == 0
27-
#error wxString converison can only handle WCHAR wxStrings currently
27+
#error wxString conversion can only handle WCHAR wxStrings currently
2828
#endif
2929

3030
// Code to test a PyObject for compatibility with wxString
@@ -45,7 +45,7 @@
4545
}
4646
}
4747
*sipCppPtr = new wxString();
48-
size_t len = PyUnicode_GET_SIZE(uni);
48+
size_t len = PyUnicode_GetSize(uni);
4949
if (len) {
5050
wxPyUnicode_AsWideChar(uni, wxStringBuffer(**sipCppPtr, len), len);
5151
}

0 commit comments

Comments
 (0)