Skip to content

Commit 49bca80

Browse files
committed
Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C code
1 parent 1e3ec33 commit 49bca80

19 files changed

Lines changed: 46 additions & 46 deletions

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/_ctypes/callproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ module _ctypes
9292
#include <sanitizer/msan_interface.h>
9393
#endif
9494

95-
#if defined(_DEBUG) || defined(__MINGW32__)
95+
#if defined(Py_DEBUG) || defined(__MINGW32__)
9696
/* Don't use structured exception handling on Windows if this is defined.
9797
MingW, AFAIK, doesn't support it.
9898
*/

Modules/_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4427,7 +4427,7 @@ _ssl__SSLContext_load_dh_params_impl(PySSLContext *self, PyObject *filepath)
44274427
FILE *f;
44284428
DH *dh;
44294429

4430-
#if defined(MS_WINDOWS) && defined(_DEBUG)
4430+
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
44314431
PyErr_SetString(PyExc_NotImplementedError,
44324432
"load_dh_params: unavailable on Windows debug build");
44334433
return NULL;

Modules/_ssl/debughelpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ _PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
175175
PySSLContext *self = PySSLContext_CAST(op);
176176
FILE *fp;
177177

178-
#if defined(MS_WINDOWS) && defined(_DEBUG)
178+
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
179179
PyErr_SetString(PyExc_NotImplementedError,
180180
"set_keylog_filename: unavailable on Windows debug build");
181181
return -1;

PC/clinic/msvcrtmodule.c.h

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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/msvcrtmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ msvcrt_ungetwch_impl(PyObject *module, int unicode_char)
415415

416416
#endif /* MS_WINDOWS_DESKTOP */
417417

418-
#ifdef _DEBUG
418+
#ifdef Py_DEBUG
419419
/*[clinic input]
420420
msvcrt.CrtSetReportFile -> HANDLE
421421
@@ -490,7 +490,7 @@ msvcrt_set_error_mode_impl(PyObject *module, int mode)
490490

491491
return res;
492492
}
493-
#endif /* _DEBUG */
493+
#endif /* Py_DEBUG */
494494

495495
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
496496

@@ -604,7 +604,7 @@ exec_module(PyObject* m)
604604
INSERTINT(m, "SEM_NOGPFAULTERRORBOX", SEM_NOGPFAULTERRORBOX);
605605
INSERTINT(m, "SEM_NOOPENFILEERRORBOX", SEM_NOOPENFILEERRORBOX);
606606
#endif
607-
#ifdef _DEBUG
607+
#ifdef Py_DEBUG
608608
INSERTINT(m, "CRT_WARN", _CRT_WARN);
609609
INSERTINT(m, "CRT_ERROR", _CRT_ERROR);
610610
INSERTINT(m, "CRT_ASSERT", _CRT_ASSERT);

PC/pyconfig.h.in

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ WIN32 is still required for the locale module.
9494
#endif
9595
#endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */
9696

97+
/* _DEBUG implies Py_DEBUG */
98+
#ifdef _DEBUG
99+
#define Py_DEBUG
100+
#endif
101+
97102
/* Define to 1 if you want to disable the GIL */
98103
/* Uncomment the definition for free-threaded builds, or define it manually
99104
* when compiling extension modules. Note that we test with #ifdef, so
@@ -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,11 +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-
383-
384384
#ifdef MS_WIN32
385385

386386
#define SIZEOF_SHORT 2

PC/pylauncher.rc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
#elif defined(PYW_ICON)
1717
1 ICON DISCARDABLE "icons\pythonw.ico"
1818
#else
19-
1 ICON DISCARDABLE "icons\launcher.ico"
20-
2 ICON DISCARDABLE "icons\py.ico"
21-
3 ICON DISCARDABLE "icons\pyc.ico"
22-
4 ICON DISCARDABLE "icons\pyd.ico"
19+
1 ICON DISCARDABLE "icons\launcher.ico"
20+
2 ICON DISCARDABLE "icons\py.ico"
21+
3 ICON DISCARDABLE "icons\pyc.ico"
22+
4 ICON DISCARDABLE "icons\pyd.ico"
2323
5 ICON DISCARDABLE "icons\python.ico"
2424
6 ICON DISCARDABLE "icons\pythonw.ico"
25-
7 ICON DISCARDABLE "icons\setup.ico"
25+
7 ICON DISCARDABLE "icons\setup.ico"
2626
#endif
2727

2828
1 USAGE "launcher-usage.txt"
@@ -37,7 +37,7 @@ VS_VERSION_INFO VERSIONINFO
3737
FILEVERSION PYVERSION64
3838
PRODUCTVERSION PYVERSION64
3939
FILEFLAGSMASK 0x3fL
40-
#ifdef _DEBUG
40+
#ifdef Py_DEBUG
4141
FILEFLAGS VS_FF_DEBUG
4242
#else
4343
FILEFLAGS 0x0L
@@ -64,4 +64,4 @@ BEGIN
6464
BEGIN
6565
VALUE "Translation", 0x0, 1200
6666
END
67-
END
67+
END

PC/pyshellext.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ VS_VERSION_INFO VERSIONINFO
2121
FILEVERSION PYVERSION64
2222
PRODUCTVERSION PYVERSION64
2323
FILEFLAGSMASK 0x3fL
24-
#ifdef _DEBUG
24+
#ifdef Py_DEBUG
2525
FILEFLAGS VS_FF_DEBUG
2626
#else
2727
FILEFLAGS 0x0L
@@ -48,4 +48,4 @@ BEGIN
4848
BEGIN
4949
VALUE "Translation", 0x0, 1200
5050
END
51-
END
51+
END

0 commit comments

Comments
 (0)