diff -Naur Python-3.8.0-orig/Include/internal/pycore_condvar.h Python-3.8.0/Include/internal/pycore_condvar.h
--- Python-3.8.0-orig/Include/internal/pycore_condvar.h	2019-10-14 16:34:47.000000000 +0300
+++ Python-3.8.0/Include/internal/pycore_condvar.h	2019-10-22 10:02:30.231300600 +0300
@@ -5,6 +5,12 @@
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+#ifdef __MINGW32__
+# if !defined(HAVE_PTHREAD_H) || defined(NT_THREADS)
+#  undef _POSIX_THREADS
+# endif
+#endif
+
 #ifndef _POSIX_THREADS
 /* This means pthreads are not implemented in libc headers, hence the macro
    not present in unistd.h. But they still can be implemented as an external
@@ -37,6 +43,10 @@
 /* include windows if it hasn't been done before */
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
+/* winpthreads are involved via windows header, so need undef _POSIX_THREADS after header include */
+#if defined(_POSIX_THREADS)
+#undef _POSIX_THREADS
+#endif
 
 /* options */
 /* non-emulated condition variables are provided for those that want
diff -Naur Python-3.8.0-orig/Include/pythread.h Python-3.8.0/Include/pythread.h
--- Python-3.8.0-orig/Include/pythread.h	2019-10-14 16:34:47.000000000 +0300
+++ Python-3.8.0/Include/pythread.h	2019-10-22 10:02:30.652501400 +0300
@@ -9,6 +9,12 @@
 extern "C" {
 #endif
 
+#ifdef __MINGW32__
+# if !defined(HAVE_PTHREAD_H) || defined(NT_THREADS)
+#  undef _POSIX_THREADS
+# endif
+#endif
+
 /* Return status codes for Python lock acquisition.  Chosen for maximum
  * backwards compatibility, ie failure -> 0, success -> 1.  */
 typedef enum PyLockStatus {
