mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-131942: Use the Python-specific Py_DEBUG
macro rather than _DEBUG
in Windows-related C code (GH-131944)
This commit is contained in:
parent
e15bbfafbc
commit
f0f93ba5fa
13 changed files with 32 additions and 28 deletions
|
@ -826,14 +826,17 @@ frequently used builds will be described in the remainder of this section.
|
||||||
|
|
||||||
Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined produces
|
Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined produces
|
||||||
what is generally meant by :ref:`a debug build of Python <debug-build>`.
|
what is generally meant by :ref:`a debug build of Python <debug-build>`.
|
||||||
:c:macro:`!Py_DEBUG` is enabled in the Unix build by adding
|
|
||||||
:option:`--with-pydebug` to the :file:`./configure` command.
|
On Unix, :c:macro:`!Py_DEBUG` can be enabled by adding :option:`--with-pydebug`
|
||||||
It is also implied by the presence of the
|
to the :file:`./configure` command. This will also disable compiler optimization.
|
||||||
not-Python-specific :c:macro:`!_DEBUG` macro. When :c:macro:`!Py_DEBUG` is enabled
|
|
||||||
in the Unix build, compiler optimization is disabled.
|
On Windows, selecting a debug build (e.g., by passing the :option:`-d` option to
|
||||||
|
:file:`PCbuild/build.bat`) automatically enables :c:macro:`!Py_DEBUG`.
|
||||||
|
Additionally, the presence of the not-Python-specific :c:macro:`!_DEBUG` macro,
|
||||||
|
when defined by the compiler, will also implicitly enable :c:macro:`!Py_DEBUG`.
|
||||||
|
|
||||||
In addition to the reference count debugging described below, extra checks are
|
In addition to the reference count debugging described below, extra checks are
|
||||||
performed, see :ref:`Python Debug Build <debug-build>`.
|
performed. See :ref:`Python Debug Build <debug-build>` for more details.
|
||||||
|
|
||||||
Defining :c:macro:`Py_TRACE_REFS` enables reference tracing
|
Defining :c:macro:`Py_TRACE_REFS` enables reference tracing
|
||||||
(see the :option:`configure --with-trace-refs option <--with-trace-refs>`).
|
(see the :option:`configure --with-trace-refs option <--with-trace-refs>`).
|
||||||
|
|
|
@ -107,7 +107,7 @@ extern int _PyImport_RunModInitFunc(
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
typedef FARPROC dl_funcptr;
|
typedef FARPROC dl_funcptr;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef Py_DEBUG
|
||||||
# define PYD_DEBUG_SUFFIX "_d"
|
# define PYD_DEBUG_SUFFIX "_d"
|
||||||
#else
|
#else
|
||||||
# define PYD_DEBUG_SUFFIX ""
|
# define PYD_DEBUG_SUFFIX ""
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Use the Python-specific :c:macro:`Py_DEBUG` macro rather than :c:macro:`!_DEBUG` in Windows-related C code. Patch by Xuehai Pan.
|
|
@ -92,7 +92,7 @@ module _ctypes
|
||||||
#include <sanitizer/msan_interface.h>
|
#include <sanitizer/msan_interface.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(__MINGW32__)
|
#if defined(Py_DEBUG) || defined(__MINGW32__)
|
||||||
/* Don't use structured exception handling on Windows if this is defined.
|
/* Don't use structured exception handling on Windows if this is defined.
|
||||||
MingW, AFAIK, doesn't support it.
|
MingW, AFAIK, doesn't support it.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4427,7 +4427,7 @@ _ssl__SSLContext_load_dh_params_impl(PySSLContext *self, PyObject *filepath)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
DH *dh;
|
DH *dh;
|
||||||
|
|
||||||
#if defined(MS_WINDOWS) && defined(_DEBUG)
|
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
|
||||||
PyErr_SetString(PyExc_NotImplementedError,
|
PyErr_SetString(PyExc_NotImplementedError,
|
||||||
"load_dh_params: unavailable on Windows debug build");
|
"load_dh_params: unavailable on Windows debug build");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -175,7 +175,7 @@ _PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
|
||||||
PySSLContext *self = PySSLContext_CAST(op);
|
PySSLContext *self = PySSLContext_CAST(op);
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
#if defined(MS_WINDOWS) && defined(_DEBUG)
|
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
|
||||||
PyErr_SetString(PyExc_NotImplementedError,
|
PyErr_SetString(PyExc_NotImplementedError,
|
||||||
"set_keylog_filename: unavailable on Windows debug build");
|
"set_keylog_filename: unavailable on Windows debug build");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -140,7 +140,7 @@ static wchar_t * get_env(wchar_t * key)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG)
|
#if defined(Py_DEBUG)
|
||||||
/* Do not define EXECUTABLEPATH_VALUE in debug builds as it'll
|
/* Do not define EXECUTABLEPATH_VALUE in debug builds as it'll
|
||||||
never point to the debug build. */
|
never point to the debug build. */
|
||||||
#if defined(_WINDOWS)
|
#if defined(_WINDOWS)
|
||||||
|
|
|
@ -94,6 +94,11 @@ WIN32 is still required for the locale module.
|
||||||
#endif
|
#endif
|
||||||
#endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */
|
#endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */
|
||||||
|
|
||||||
|
/* _DEBUG implies Py_DEBUG */
|
||||||
|
#ifdef _DEBUG
|
||||||
|
# define Py_DEBUG 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you want to disable the GIL */
|
/* Define to 1 if you want to disable the GIL */
|
||||||
/* Uncomment the definition for free-threaded builds, or define it manually
|
/* Uncomment the definition for free-threaded builds, or define it manually
|
||||||
* when compiling extension modules. Note that we test with #ifdef, so
|
* 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 */
|
||||||
This is relevant when using build-system generator (e.g CMake) where
|
This is relevant when using build-system generator (e.g CMake) where
|
||||||
the linking is explicitly handled */
|
the linking is explicitly handled */
|
||||||
# if defined(Py_GIL_DISABLED)
|
# if defined(Py_GIL_DISABLED)
|
||||||
# if defined(_DEBUG)
|
# if defined(Py_DEBUG)
|
||||||
# pragma comment(lib,"python315t_d.lib")
|
# pragma comment(lib,"python315t_d.lib")
|
||||||
# elif defined(Py_LIMITED_API)
|
# elif defined(Py_LIMITED_API)
|
||||||
# pragma comment(lib,"python3t.lib")
|
# pragma comment(lib,"python3t.lib")
|
||||||
# else
|
# else
|
||||||
# pragma comment(lib,"python315t.lib")
|
# pragma comment(lib,"python315t.lib")
|
||||||
# endif /* _DEBUG */
|
# endif /* Py_DEBUG */
|
||||||
# else /* Py_GIL_DISABLED */
|
# else /* Py_GIL_DISABLED */
|
||||||
# if defined(_DEBUG)
|
# if defined(Py_DEBUG)
|
||||||
# pragma comment(lib,"python315_d.lib")
|
# pragma comment(lib,"python315_d.lib")
|
||||||
# elif defined(Py_LIMITED_API)
|
# elif defined(Py_LIMITED_API)
|
||||||
# pragma comment(lib,"python3.lib")
|
# pragma comment(lib,"python3.lib")
|
||||||
# else
|
# else
|
||||||
# pragma comment(lib,"python315.lib")
|
# pragma comment(lib,"python315.lib")
|
||||||
# endif /* _DEBUG */
|
# endif /* Py_DEBUG */
|
||||||
# endif /* Py_GIL_DISABLED */
|
# endif /* Py_GIL_DISABLED */
|
||||||
# endif /* _MSC_VER && !Py_NO_LINK_LIB */
|
# endif /* _MSC_VER && !Py_NO_LINK_LIB */
|
||||||
# endif /* Py_BUILD_CORE */
|
# endif /* Py_BUILD_CORE */
|
||||||
|
@ -376,11 +381,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
|
||||||
# define ALIGNOF_MAX_ALIGN_T 8
|
# define ALIGNOF_MAX_ALIGN_T 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
# define Py_DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
|
|
||||||
#define SIZEOF_SHORT 2
|
#define SIZEOF_SHORT 2
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
#include <winrt\Windows.Storage.h>
|
#include <winrt\Windows.Storage.h>
|
||||||
|
|
||||||
#ifdef PYTHONW
|
#ifdef PYTHONW
|
||||||
#ifdef _DEBUG
|
#ifdef Py_DEBUG
|
||||||
const wchar_t *PROGNAME = L"pythonw_d.exe";
|
const wchar_t *PROGNAME = L"pythonw_d.exe";
|
||||||
#else
|
#else
|
||||||
const wchar_t *PROGNAME = L"pythonw.exe";
|
const wchar_t *PROGNAME = L"pythonw.exe";
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef _DEBUG
|
#ifdef Py_DEBUG
|
||||||
const wchar_t *PROGNAME = L"python_d.exe";
|
const wchar_t *PROGNAME = L"python_d.exe";
|
||||||
#else
|
#else
|
||||||
const wchar_t *PROGNAME = L"python.exe";
|
const wchar_t *PROGNAME = L"python.exe";
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define MS_WINDOWS
|
#define MS_WINDOWS
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
#include "patchlevel.h"
|
#include "patchlevel.h"
|
||||||
#ifdef _DEBUG
|
#ifdef Py_DEBUG
|
||||||
# define PYTHON_DEBUG_EXT "_d"
|
# define PYTHON_DEBUG_EXT "_d"
|
||||||
#else
|
#else
|
||||||
# define PYTHON_DEBUG_EXT
|
# define PYTHON_DEBUG_EXT
|
||||||
|
|
|
@ -108,7 +108,7 @@ static char *GetPythonImport (HINSTANCE hModule)
|
||||||
char *pch;
|
char *pch;
|
||||||
|
|
||||||
/* Don't claim that python3.dll is a Python DLL. */
|
/* Don't claim that python3.dll is a Python DLL. */
|
||||||
#ifdef _DEBUG
|
#ifdef Py_DEBUG
|
||||||
if (strcmp(import_name, "python3_d.dll") == 0) {
|
if (strcmp(import_name, "python3_d.dll") == 0) {
|
||||||
#else
|
#else
|
||||||
if (strcmp(import_name, "python3.dll") == 0) {
|
if (strcmp(import_name, "python3.dll") == 0) {
|
||||||
|
@ -120,7 +120,7 @@ static char *GetPythonImport (HINSTANCE hModule)
|
||||||
/* Ensure python prefix is followed only
|
/* Ensure python prefix is followed only
|
||||||
by numbers to the end of the basename */
|
by numbers to the end of the basename */
|
||||||
pch = import_name + 6;
|
pch = import_name + 6;
|
||||||
#ifdef _DEBUG
|
#ifdef Py_DEBUG
|
||||||
while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') {
|
while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') {
|
||||||
#else
|
#else
|
||||||
while (*pch && *pch != '.') {
|
while (*pch && *pch != '.') {
|
||||||
|
@ -300,7 +300,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
PyOS_snprintf(buffer, sizeof(buffer),
|
PyOS_snprintf(buffer, sizeof(buffer),
|
||||||
#ifdef _DEBUG
|
#ifdef Py_DEBUG
|
||||||
"python%d%d_d.dll",
|
"python%d%d_d.dll",
|
||||||
#else
|
#else
|
||||||
"python%d%d.dll",
|
"python%d%d.dll",
|
||||||
|
|
|
@ -38,7 +38,7 @@ module marshal
|
||||||
* On Windows PGO builds, the r_object function overallocates its stack and
|
* On Windows PGO builds, the r_object function overallocates its stack and
|
||||||
* can cause a stack overflow. We reduce the maximum depth for all Windows
|
* can cause a stack overflow. We reduce the maximum depth for all Windows
|
||||||
* releases to protect against this.
|
* releases to protect against this.
|
||||||
* #if defined(MS_WINDOWS) && defined(_DEBUG)
|
* #if defined(MS_WINDOWS) && defined(Py_DEBUG)
|
||||||
*/
|
*/
|
||||||
#if defined(MS_WINDOWS)
|
#if defined(MS_WINDOWS)
|
||||||
# define MAX_MARSHAL_STACK_DEPTH 1000
|
# define MAX_MARSHAL_STACK_DEPTH 1000
|
||||||
|
|
|
@ -3144,7 +3144,7 @@ static inline void _Py_NO_RETURN
|
||||||
fatal_error_exit(int status)
|
fatal_error_exit(int status)
|
||||||
{
|
{
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
#if defined(MS_WINDOWS) && defined(_DEBUG)
|
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
|
||||||
DebugBreak();
|
DebugBreak();
|
||||||
#endif
|
#endif
|
||||||
abort();
|
abort();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue