summarylogtreecommitdiffstats
path: root/0105-ctypes-find_library-c-should-return-None-with-ucrt.patch
blob: 1352c0210adadcf2b53098a0ce78c6e94046e531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From bf97e2d2da502effd0116a00d4a02a69b7a9c2a9 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 105/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 0c2510e..48ddb3b 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):
-- 
2.33.0