Skip to content

Commit 93257be

Browse files
committed
Prefer Py_DEBUG over _DEBUG
1 parent 584e0b0 commit 93257be

File tree

8 files changed

+18
-24
lines changed

8 files changed

+18
-24
lines changed

Include/internal/pycore_importdl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extern int _PyImport_RunModInitFunc(
107107
#include <windows.h>
108108
typedef FARPROC dl_funcptr;
109109

110-
#ifdef _DEBUG
110+
#ifdef Py_DEBUG
111111
# define PYD_DEBUG_SUFFIX "_d"
112112
#else
113113
# define PYD_DEBUG_SUFFIX ""

Modules/_sysconfig.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@ _sysconfig_config_vars_impl(PyObject *module)
6565
"t"
6666
# endif
6767
# ifdef Py_DEBUG
68-
# ifndef _DEBUG
69-
# error "_DEBUG not defined while Py_DEBUG is defined on Windows"
70-
# endif
7168
"d"
72-
# else
73-
# ifdef _DEBUG
74-
# error "_DEBUG defined while Py_DEBUG is not defined on Windows"
75-
# endif
7669
# endif
7770
"")
7871
< 0) {

PC/launcher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static wchar_t * get_env(wchar_t * key)
140140
return buf;
141141
}
142142

143-
#if defined(_DEBUG)
143+
#if defined(Py_DEBUG)
144144
/* Do not define EXECUTABLEPATH_VALUE in debug builds as it'll
145145
never point to the debug build. */
146146
#if defined(_WINDOWS)

PC/pyconfig.h.in

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ typedef int pid_t;
289289
# include <stdio.h>
290290
#endif
291291

292+
// _DEBUG implies Py_DEBUG
293+
#ifdef _DEBUG
294+
# define Py_DEBUG
295+
#endif
296+
292297
/* 64 bit ints are usually spelt __int64 unless compiler has overridden */
293298
#ifndef PY_LONG_LONG
294299
# define PY_LONG_LONG __int64
@@ -319,21 +324,21 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
319324
This is relevant when using build-system generator (e.g CMake) where
320325
the linking is explicitly handled */
321326
# if defined(Py_GIL_DISABLED)
322-
# if defined(_DEBUG)
327+
# if defined(Py_DEBUG)
323328
# pragma comment(lib,"python314t_d.lib")
324329
# elif defined(Py_LIMITED_API)
325330
# pragma comment(lib,"python3t.lib")
326331
# else
327332
# pragma comment(lib,"python314t.lib")
328-
# endif /* _DEBUG */
333+
# endif /* Py_DEBUG */
329334
# else /* Py_GIL_DISABLED */
330-
# if defined(_DEBUG)
335+
# if defined(Py_DEBUG)
331336
# pragma comment(lib,"python314_d.lib")
332337
# elif defined(Py_LIMITED_API)
333338
# pragma comment(lib,"python3.lib")
334339
# else
335340
# pragma comment(lib,"python314.lib")
336-
# endif /* _DEBUG */
341+
# endif /* Py_DEBUG */
337342
# endif /* Py_GIL_DISABLED */
338343
# endif /* _MSC_VER && !Py_NO_LINK_LIB */
339344
# endif /* Py_BUILD_CORE */
@@ -376,10 +381,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
376381
# define ALIGNOF_MAX_ALIGN_T 8
377382
#endif
378383

379-
#ifdef _DEBUG
380-
# define Py_DEBUG
381-
#endif
382-
383384

384385
#ifdef MS_WIN32
385386

PC/python_uwp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
#include <winrt\Windows.Storage.h>
2020

2121
#ifdef PYTHONW
22-
#ifdef _DEBUG
22+
#ifdef Py_DEBUG
2323
const wchar_t *PROGNAME = L"pythonw_d.exe";
2424
#else
2525
const wchar_t *PROGNAME = L"pythonw.exe";
2626
#endif
2727
#else
28-
#ifdef _DEBUG
28+
#ifdef Py_DEBUG
2929
const wchar_t *PROGNAME = L"python_d.exe";
3030
#else
3131
const wchar_t *PROGNAME = L"python.exe";

PC/python_ver_rc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define MS_WINDOWS
1111
#include "modsupport.h"
1212
#include "patchlevel.h"
13-
#ifdef _DEBUG
13+
#ifdef Py_DEBUG
1414
# define PYTHON_DEBUG_EXT "_d"
1515
#else
1616
# define PYTHON_DEBUG_EXT

PCbuild/pyproject.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<PropertyGroup>
4444
<_DebugPreprocessorDefinition>NDEBUG;</_DebugPreprocessorDefinition>
45-
<_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG;</_DebugPreprocessorDefinition>
45+
<_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG;Py_DEBUG;</_DebugPreprocessorDefinition>
4646
<_PyStatsPreprocessorDefinition>PyStats;</_PyStatsPreprocessorDefinition>
4747
<_PyStatsPreprocessorDefinition Condition="$(PySTATS) != ''">Py_STATS;</_PyStatsPreprocessorDefinition>
4848
<_PlatformPreprocessorDefinition>_WIN32;</_PlatformPreprocessorDefinition>

Python/dynload_win.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static char *GetPythonImport (HINSTANCE hModule)
108108
char *pch;
109109

110110
/* Don't claim that python3.dll is a Python DLL. */
111-
#ifdef _DEBUG
111+
#ifdef Py_DEBUG
112112
if (strcmp(import_name, "python3_d.dll") == 0) {
113113
#else
114114
if (strcmp(import_name, "python3.dll") == 0) {
@@ -120,7 +120,7 @@ static char *GetPythonImport (HINSTANCE hModule)
120120
/* Ensure python prefix is followed only
121121
by numbers to the end of the basename */
122122
pch = import_name + 6;
123-
#ifdef _DEBUG
123+
#ifdef Py_DEBUG
124124
while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') {
125125
#else
126126
while (*pch && *pch != '.') {
@@ -300,7 +300,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
300300
char buffer[256];
301301

302302
PyOS_snprintf(buffer, sizeof(buffer),
303-
#ifdef _DEBUG
303+
#ifdef Py_DEBUG
304304
"python%d%d_d.dll",
305305
#else
306306
"python%d%d.dll",

0 commit comments

Comments
 (0)