From 5e7f059b5d94cb624764a6b0b42c1186a27e6a80 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Fri, 23 Jul 2021 18:23:58 +0200
Subject: [PATCH 056/N] ctypes: find_library('c') should return None with
 ucrt

Just like with MSVC. This fixes a test in test_ctypes.
---
 Lib/ctypes/util.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index c550883..a5a2a3f 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -31,6 +31,12 @@ if os.name == "nt":
         # else we don't know what version of the compiler this is
         return None
 
+    def find_msvcrt_mingw():
+        is_ucrt = 'clang' in sys.version.lower() or 'ucrt' in sys.version.lower()
+        if is_ucrt:
+            return None
+        return 'msvcrt.dll'
+
     def find_msvcrt():
         """Return the name of the VC runtime dll"""
         version = _get_build_version()
@@ -54,6 +60,9 @@ if os.name == "nt":
 
     def find_library(name):
         if name in ('c', 'm'):
+            import sysconfig
+            if sysconfig.get_platform().startswith('mingw'):
+                return find_msvcrt_mingw()
             return find_msvcrt()
         # See MSDN for the REAL search order.
         for directory in os.environ['PATH'].split(os.pathsep):
