Skip to content

gh-000000: Convert PyBytes_Check macro to a function#149558

Draft
bschoenmaeckers wants to merge 6 commits intopython:mainfrom
bschoenmaeckers:bool_check_static_function
Draft

gh-000000: Convert PyBytes_Check macro to a function#149558
bschoenmaeckers wants to merge 6 commits intopython:mainfrom
bschoenmaeckers:bool_check_static_function

Conversation

@bschoenmaeckers
Copy link
Copy Markdown

As discussed at https://discuss.python.org/t/c-api-add-py-getbuildintype-and-py-getbuildintypeborrowed/107010/12.

This converts the first type check macro to a function export instead when compiling for the limited api.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 8, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 8, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bschoenmaeckers bschoenmaeckers force-pushed the bool_check_static_function branch from 112f4a9 to df45d6b Compare May 8, 2026 12:45
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 8, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32606787 | 📁 Comparing 63e3c03 against main (5784119)

  🔍 Preview build  

4 files changed
± c-api/bool.html
± c-api/stable.html
± whatsnew/3.16.html
± whatsnew/changelog.html

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 8, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Comment thread Lib/test/test_stable_abi_ctypes.py
Comment thread Include/boolobject.h Outdated
Comment thread Objects/boolobject.c Outdated
Comment on lines +26 to +33
#undef PyBool_Check

int
PyBool_Check(PyObject *x)
{
return Py_IS_TYPE(x, &PyBool_Type);
}

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.

These should be at the end of the file, so all the internal implementations see the macro version.


These will become repetitive enough that I'd prefer condensed formatting (per the first rule in PEP 7):

// Implementations for the Stable ABI

#undef PyBool_Check
int PyBool_Check(PyObject *x) { return Py_IS_TYPE(x, &PyBool_Type); }

But @vstinner might disagree with that :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've moved it to the end of the file and used the condensed formatting.

Comment thread Include/boolobject.h Outdated
Comment thread Lib/test/test_stable_abi_ctypes.py
Co-authored-by: Petr Viktorin <encukou@gmail.com>
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 8, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

2 similar comments
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 8, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 8, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

bschoenmaeckers and others added 2 commits May 8, 2026 18:28
Co-authored-by: Petr Viktorin <encukou@gmail.com>
@bschoenmaeckers bschoenmaeckers force-pushed the bool_check_static_function branch from 63e3c03 to f2a576f Compare May 8, 2026 16:29
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 8, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Sign up for free to 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.

3 participants