Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PY_SSIZE_T_CLEAN not defined #52

Open
menschel opened this issue Dec 25, 2022 · 2 comments
Open

PY_SSIZE_T_CLEAN not defined #52

menschel opened this issue Dec 25, 2022 · 2 comments

Comments

@menschel
Copy link

Hello, I ran into this issue after upgrading from Python 3.9 to Python 3.11 recently.

Apparently the MACRO PY_SSIZE_T_CLEAN must be defined in py3c.h before including python.h

https://docs.python.org/3/c-api/arg.html#strings-and-buffers

Otherwise it leads to
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

@encukou
Copy link
Owner

encukou commented Jan 2, 2023

In addition to defining PY_SSIZE_T_CLEAN, you also need to ensure you use Py_ssize_t rather than int in any calls that use the # formats. So, py3c shouldn't simply define PY_SSIZE_T_CLEAN for you -- that would be inviting data corruption.

This should be explained in the text, however.

@menschel
Copy link
Author

menschel commented Jan 3, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants