equinor / segyio

Fast Python library for SEGY files.
Other
471 stars 213 forks source link

Use Py_ssize_t for type-length arguments #490

Closed jokva closed 3 years ago

jokva commented 3 years ago

The with-length argument type specifier would be either int or Py_ssize_t, depending on the PY_SSIZE_T_CLEAN macro being defined.

From the docs: For all # variants of formats (s#, y#, etc.), the type of the length argument (int or Py_ssize_t) is controlled by defining the macro PY_SSIZE_T_CLEAN before including Python.h. If the macro was defined, length is a Py_ssize_t rather than an int. This behavior will change in a future Python version to only support Py_ssize_t and drop int support. It is best to always define PY_SSIZE_T_CLEAN.

https://docs.python.org/3/c-api/arg.html#arg-parsing

In python3.8, using ints for lengths (i.e. not defining PY_SSIZE_T_CLEAN) is considered deprecated, and in future versions of python only Py_ssize_t will be legal.

From the docs: It is recommended to always define PY_SSIZE_T_CLEAN before including Python.h. See Parsing arguments and building values for a description of this macro.

https://docs.python.org/3/c-api/intro.html

jokva commented 3 years ago

Closes #484

gsakkis commented 3 years ago

Could you please push a new PyPI release with this fix?