-
Notifications
You must be signed in to change notification settings - Fork 12
fix: handle pybind11 macro defined as 0 instead of non-exist
#227
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #227 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 1403 1403
Branches 173 173
=========================================
Hits 1403 1403 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a helper macro to correctly detect macros defined as 0 and updates several build‐time flag checks to use it.
- Define
NONZERO_OR_EMPTYto distinguish between macros defined as0vs. undefined/empty. - Apply the new check to Python and pybind11 feature flags.
- Undefine the helper macro after use.
Comments suppressed due to low confidence (3)
src/optree.cpp:67
- There are no tests covering the scenario where these build macros are defined as 0; consider adding tests that compile with macros explicitly set to 0 to verify the expected boolean behavior.
#if defined(Py_DEBUG) && NONZERO_OR_EMPTY(Py_DEBUG)
src/optree.cpp:56
- [nitpick] The macro name
NONZERO_OR_EMPTYis generic and could conflict; consider prefixing it (e.g.,OPTREE_NONZERO_OR_EMPTY) to avoid potential naming collisions.
#define NONZERO_OR_EMPTY(MACRO) ((MACRO + 0 != 0) || (0 - MACRO - 1 >= 0))
src/optree.cpp:84
- [nitpick] This line break and indentation make the condition hard to read; consider reformatting the
#ifinto multiple lines with aligned operators for clarity.
#if defined(PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT) && \
pybind11 macro defined as 0 instead of non-exist
d54764a to
7eb87d5
Compare
Description
Describe your changes in detail.
Motivation and Context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax
close #15213if this solves the issue #15213Related:
Checklist
Go over all the following points, and put an
xin all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!
make format. (required)make lint. (required)make testpass. (required)