Error while running python3-fail2ban with "PY_SSIZE_T_CLEAN macro must be defined for '#' formats"

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Error while running python3-fail2ban with "PY_SSIZE_T_CLEAN macro must be defined for '#' formats"

2,937 次查看
zahir
Contributor I

I'm trying to run the python3-fail2ban component built by Yocto Kirkstone, but I'm encountering an error related to the "PY_SSIZE_T_CLEAN macro". The error message is PY_SSIZE_T_CLEAN macro must be defined for '#' formats.

I've looked into the issue and found that in the Python 3.10 C-API documentation https://docs.python.org/3.10/c-api/arg.html#arg-parsing, it's mentioned that,

for all # variants of formats (like s#, y#, etc.), the PY_SSIZE_T_CLEAN macro must be defined before including Python.h. Additionally, it's stated that in Python 3.9 and older, the type of the length argument is Py_ssize_t if the PY_SSIZE_T_CLEAN macro is defined, or int otherwise.

  1. I tried to resolve this issue by defining the PY_SSIZE_T_CLEAN macro before including Python.h. But the issue was not resolved, patch snippet here,

+#ifndef PY_SSIZE_T_CLEAN
+#define PY_SSIZE_T_CLEAN 1
+#endif
#include "Python.h"

  1. Also included CFLAGS += "PY_SSIZE_T_CLEAN " in the python3-fail2ban component. No impact on observation

  2. Later, tried to add CFLAGS += "PY_SSIZE_T_CLEAN " in the python3 component directly, but it creates lots of build issues in yocto python3, seems like not recommended

I'm using Yocto with a specific version of python3-fail2ban (0.11.2) and python3(10.12), and I've verified that the necessary PY_SSIZE_T_CLEAN macro is defined before including Python.h.

Despite this, the error persists. Has anyone encountered a similar issue when running python3-fail2ban? Are there any additional steps or configurations that need to be done to properly include the PY_SSIZE_T_CLEAN macro? I'd appreciate any insights or suggestions to resolve this issue.

Thanks in advance!

0 项奖励
回复
1 回复