Skip to content

y# arg parser requires PY_SSIZE_T_CLEAN and a Py_ssize_t type for length #8

@jaqx0r

Description

@jaqx0r

Compiling pyao with Python 3.11, and this example program, leads to an error at runtime:

$ python                 
Python 3.11.5 (main, Aug 29 2023, 15:31:31) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ao
>>> dev = ao.AudioDevice(0)
>>> with open('/home/jaq/bucket/buckaroo2.wav', 'rb') as f:
...   dev.play(f.read())
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

https://docs.python.org/3/c-api/arg.html#strings-and-buffers indicates we should now be setting this in aomodule.h before Python.h is included.

We also then need to change len on aomodule.c:367 to be of type Py_ssize_t otherwise PyArg_ParseTuple does not decode the argument into &samples, returning a MemoryError from line 381.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions