diff --git a/Include/exports.h b/Include/exports.h index 62feb09ed2b433..73f0a1fca8102e 100644 --- a/Include/exports.h +++ b/Include/exports.h @@ -26,7 +26,7 @@ #endif #if defined(_WIN32) || defined(__CYGWIN__) - #if defined(Py_ENABLE_SHARED) + #if !defined(Py_BUILD_CORE) || defined(Py_ENABLE_SHARED) #define Py_IMPORTED_SYMBOL __declspec(dllimport) #define Py_EXPORTED_SYMBOL __declspec(dllexport) #define Py_LOCAL_SYMBOL diff --git a/Misc/NEWS.d/next/C_API/2025-11-17-17-46-16.gh-issue-141671.cVXNW5.rst b/Misc/NEWS.d/next/C_API/2025-11-17-17-46-16.gh-issue-141671.cVXNW5.rst new file mode 100644 index 00000000000000..5dd6913522ecc3 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2025-11-17-17-46-16.gh-issue-141671.cVXNW5.rst @@ -0,0 +1,2 @@ +:c:macro:`PyMODINIT_FUNC` (and the new :c:macro:`!PyMODEXPORT_FUNC`) now adds +a linkage declaration (``__declspec(dllexport)``) on Windows.