Skip to content

Commit

Permalink
python: Use new Py_SET_SIZE API introduced in Python 3.9
Browse files Browse the repository at this point in the history
Fixes compile error using Python 3.10 while keeping backwards compatibility
  • Loading branch information
darktohka committed Oct 7, 2020
1 parent 418c0ca commit 18baaac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Alexandre Bonnetain
Darvame Hleran
Sokolov Yura <[email protected]>
Marcin Lulek <[email protected]>
Derzsi Dániel <[email protected]>
2 changes: 1 addition & 1 deletion plugins/python/uwsgi_pymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ PyObject *py_uwsgi_sharedarea_read(PyObject * self, PyObject * args) {
}

// HACK: we are safe as rlen can only be lower or equal to len
Py_SIZE(ret) = rlen;
Py_SET_SIZE((PyVarObject *) ret, rlen);

return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/python/uwsgi_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
#define PYTHREE
#endif

#if (PY_VERSION_HEX < 0x02060000)
#ifndef Py_SIZE
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
#if (PY_VERSION_HEX < 0x03090000)
#ifndef Py_SET_SIZE
#define Py_SET_SIZE(o, size) ((o)->ob_size = (size))
#endif
#endif

Expand Down

0 comments on commit 18baaac

Please sign in to comment.