Skip to content

gh-131942: Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C code - #131944

Merged
zooba merged 22 commits into
python:mainfrom
XuehaiPan:windows-use-py-debug
May 8, 2025
Merged

gh-131942: Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C code#131944
zooba merged 22 commits into
python:mainfrom
XuehaiPan:windows-use-py-debug

Conversation

@XuehaiPan

@XuehaiPanXuehaiPan commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

Changes:

  1. Move the definition of Py_DEBUG in PC/pyconfig.h.in to the top of the file.
/* _DEBUG implies Py_DEBUG */#ifdef_DEBUG#definePy_DEBUG#endif
  1. Change usage of _DEBUG to Py_DEBUG by using the regex /\b_DEBUG\b/.
  2. Update the generated files via make regen-all.

Since the sysconfig.h is included in all C headers with top precedence. This PR does not have any user-side visible changes.

#ifndefPy_PYTHON_H
#definePy_PYTHON_H
// Since this is a "meta-include" file, "#ifdef __cplusplus / extern "C" {"
// is not needed.
// Include Python header files
#include"patchlevel.h"
#include"pyconfig.h"
#include"pymacconfig.h"

Resolves#131942

@XuehaiPanXuehaiPan changed the title Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C codegh-131942: Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C codeMar 31, 2025
@XuehaiPan
XuehaiPan marked this pull request as ready for review March 31, 2025 16:40
@brettcannon
brettcannon removed their request for review March 31, 2025 19:53
Comment threadPC/pyconfig.h.in
Comment threadPC/pyconfig.h.in Outdated
@vstinner

Copy link
Copy Markdown
Member

cc @zooba@zware

@python-cla-bot

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@gpshead
gpshead removed their request for review April 7, 2025 04:00

@zoobazooba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the documentation isn't required, but if you're going to, we should document the Windows behaviour on the same level as the Unix behaviour (that is, don't put it in a "note"), and should also make the whole section make sense.

Comment threadDoc/c-api/intro.rst Outdated
Comment threadPC/msvcrtmodule.c Outdated
Comment threadPC/msvcrtmodule.c Outdated
@XuehaiPan
XuehaiPan requested a review from zoobaApril 11, 2025 13:28
@zooba

zooba commented May 8, 2025

Copy link
Copy Markdown
Member

Apologies for the delays, and thanks for the updates.

Once CI passes, this will merge automatically. Thanks!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C code

5 participants

@XuehaiPan@vstinner@zooba@picnixz@Huzumak1