Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

XuehaiPan
Copy link
Contributor

@XuehaiPan XuehaiPan commented Mar 31, 2025

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
#define Py_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.

#ifndef Py_PYTHON_H
#define Py_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

@XuehaiPan XuehaiPan changed the title Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C code gh-131942: Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C code Mar 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
XuehaiPan and others added 2 commits April 3, 2025 00:41
@vstinner
Copy link
Member

vstinner commented Apr 2, 2025

cc @zooba @zware

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 6, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

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

@zooba zooba left a comment

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.

@XuehaiPan XuehaiPan requested a review from zooba April 11, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
4 participants