From d8e29bae1c952ea5407d6919c46def86cb404548 Mon Sep 17 00:00:00 2001
From: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Date: Mon, 6 Feb 2023 20:28:31 +0000
Subject: [PATCH 1/2] gh-101614: don't treat python3_d.dll as a Python dll

---
 Python/dynload_win.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index c03bc5602bffee..7bd04d573df4ad 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -125,14 +125,15 @@ static char *GetPythonImport (HINSTANCE hModule)
                 !strncmp(import_name,"python",6)) {
                 char *pch;
 
-#ifndef _DEBUG
-                /* In a release version, don't claim that python3.dll is
-                   a Python DLL. */
+                /* Don't claim that python3.dll is a Python DLL. */
+#ifdef _DEBUG
+                if (strcmp(import_name, "python3_d.dll") == 0) {
+#else
                 if (strcmp(import_name, "python3.dll") == 0) {
+#endif
                     import_data += 20;
                     continue;
                 }
-#endif
 
                 /* Ensure python prefix is followed only
                    by numbers to the end of the basename */

From 40975a60d5629e01c23575efc9ba955bab69e40d Mon Sep 17 00:00:00 2001
From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com>
Date: Tue, 7 Feb 2023 18:22:56 +0000
Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?=
 =?UTF-8?q?rb=5Fit.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../next/Windows/2023-02-07-18-22-54.gh-issue-101614.NjVP0n.rst  | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 Misc/NEWS.d/next/Windows/2023-02-07-18-22-54.gh-issue-101614.NjVP0n.rst

diff --git a/Misc/NEWS.d/next/Windows/2023-02-07-18-22-54.gh-issue-101614.NjVP0n.rst b/Misc/NEWS.d/next/Windows/2023-02-07-18-22-54.gh-issue-101614.NjVP0n.rst
new file mode 100644
index 00000000000000..8ed0995d78925b
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2023-02-07-18-22-54.gh-issue-101614.NjVP0n.rst
@@ -0,0 +1 @@
+Correctly handle extensions built against debug binaries that reference ``python3_d.dll``.