PyAPI: support Python 3.13

- `_PySet_NextEntry` has been removed, use generic iterator access
  which will has some additional overhead as it needs to create
  an iterator to access the values.

- Add v3.13 compatibility defines to account for renaming:
  _PyObject_LookupAttr -> PyObject_GetOptionalAttr
  _PyLong_AsInt -> PyLong_AsInt

- Unfortunately use of Python's internal API needs to be used to
  inspect op-codes in `bpy_driver.cc`.

Testing GLTF/FBX IO there isn't any significant performance impact
from these changes.

Resolves #123871.
This commit is contained in:
Campbell Barton
2024-10-18 12:23:34 +11:00
parent 9da2589f5a
commit d9f38fca5f
10 changed files with 218 additions and 132 deletions

View File

@@ -286,14 +286,14 @@ static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach
return false;
}
if (c_texture && _PyUnicode_EqualToASCIIString(key, c_texture)) {
if (c_texture && PyUnicode_CompareWithASCIIString(key, c_texture)) {
/* Compare only once. */
c_texture = nullptr;
if (!bpygpu_ParseTexture(value, &tmp_attach.tex)) {
return false;
}
}
else if (c_layer && _PyUnicode_EqualToASCIIString(key, c_layer)) {
else if (c_layer && PyUnicode_CompareWithASCIIString(key, c_layer)) {
/* Compare only once. */
c_layer = nullptr;
tmp_attach.layer = PyLong_AsLong(value);
@@ -301,7 +301,7 @@ static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach
return false;
}
}
else if (c_mip && _PyUnicode_EqualToASCIIString(key, c_mip)) {
else if (c_mip && PyUnicode_CompareWithASCIIString(key, c_mip)) {
/* Compare only once. */
c_mip = nullptr;
tmp_attach.mip = PyLong_AsLong(value);