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

Python above version 3.9 is not supported #5

Closed
nmnsnv opened this issue Oct 26, 2023 · 1 comment · Fixed by #6
Closed

Python above version 3.9 is not supported #5

nmnsnv opened this issue Oct 26, 2023 · 1 comment · Fixed by #6
Assignees
Labels
bug Something isn't working

Comments

@nmnsnv
Copy link
Owner

nmnsnv commented Oct 26, 2023

We fail to run SAR on Python versions above 3.9 because of this and receive the following error

>>> sar.add_regexp(".+", lambda f, t: print(f"Match!"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<SOME-PATH>/python3.11/site-packages/regexp_sar/__init__.py", line 13, in add_regexp
    _regexp_sar_c.add_regexp(self._internal_sar_object, regexp, callback)
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

This is caused because of Pythons C-API change for versions above 3.9.
Per Pythons C-API docs:

For all # variants of formats (s#, y#, etc.), the macro PY_SSIZE_T_CLEAN must be defined before including Python.h. On Python 3.9 and older, the type of the length argument is [Py_ssize_t](https://docs.python.org/3/c-api/intro.html#c.Py_ssize_t) if the PY_SSIZE_T_CLEAN macro is defined, or int otherwise.
@nmnsnv nmnsnv self-assigned this Nov 3, 2023
@nmnsnv
Copy link
Owner Author

nmnsnv commented Nov 3, 2023

The issue was fixed by updating Pythons API and defining PY_SSIZE_T_CLEAN.
New version released.

@nmnsnv nmnsnv closed this as completed Nov 3, 2023
@nmnsnv nmnsnv added the bug Something isn't working label Nov 3, 2023
@nmnsnv nmnsnv linked a pull request Nov 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant