diff --git a/src/PythonQtPythonInclude.h b/src/PythonQtPythonInclude.h index 673db874f..90569ddd5 100644 --- a/src/PythonQtPythonInclude.h +++ b/src/PythonQtPythonInclude.h @@ -142,4 +142,19 @@ #define PyBytes_FromStringAndSize PyString_FromStringAndSize #endif +// Avoid clashes with libstdc++ by undefining ctype macros +// that CPython may introduce on macOS when the UTF-8 ctype quirk is enabled. +// (_PY_PORT_CTYPE_UTF8_ISSUE is defined by CPython’s pyport.h; we apply these +// undefs only in C++ builds.) +#if defined(_PY_PORT_CTYPE_UTF8_ISSUE) && defined(__cplusplus) +#undef isalnum +#undef isalpha +#undef islower +#undef isspace +#undef isupper +#undef tolower +#undef toupper #endif + +#endif +