-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-35081: Remove Py_BUILD_CORE from datetime.h #10416
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
I added "skip news": this change doesn't change the C API. But you may mention that this change fix the header when datetime.h is included in a C file compiled with Py_BUILD_CORE. |
40cfc6e
to
45df0bb
Compare
@vstinner Thanks! I added a news blurb before you did that, so I've just modified it to mention that it fixes a bug. Let me know if you think that mischaracterizes the bug that was fixed. |
I still don't understand what issue this PR fixes. If I understood correctly, including |
@serhiy-storchaka I also think that if I understand correctly, to the extent that this fixes a "bug", it's basically a bug in an unsupported workflow. I think the most likely scenario in which this bug would manifest is if some other module in CPython that does build with But really all the
I think 3 could be a breaking change, so I'm not really in favor of that right now. I don't know what the consequences of 2 are - maybe that's a viable option? There are also a number of hybrid approaches that we can take, like wrapping only the problematic I think we should start with 1, though, because it's already done and it doesn't in any way preclude switching over to 2 or 3. It also avoids the problem (which may indeed be a bug) that something else in CPython that does build with |
Misc/NEWS.d/next/C API/2018-11-08-10-54-25.bpo-35081.QVLDPr.rst
Outdated
Show resolved
Hide resolved
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.
LGTM... my review is unfair since I wrote the initial change :-)
I suggested to remove the NEWS entry. Well, the NEWS entry is good, but it might confuse people who are not used to CPython internals.
@abalkin: Would you mind to review this change?
Should we remove the news blurb? |
45df0bb
to
f624f90
Compare
I rebased against master and added a commit removing the news blurb. If you want to keep the news blurb, just revert that commit. Whoever merges, please make sure the commit message from the first commit is retained. |
9dfac52
to
cfa6016
Compare
Datetime macros like PyDate_Check() have two implementations, one using the C API capsule and one using direct access to the datetime type symbols defined in _datetimemodule.c. Since the direct access versions of the macros are only used in _datetimemodule.c, they have been moved out of "datetime.h" and into _datetimemodule.c. The _PY_DATETIME_IMPL macro is currently necessary in order to avoid both duplicate definitions of these macros in _datetimemodule.c and unnecessary declarations of C API capsule-related macros and varibles in datetime.h. A future refactoring that obviates the need for _PY_DATETIME_IMPL would be welcome if it could be done in a backwards-compatible way. Fixes bpo-35081 Co-Authored-By: vstinner <[email protected]>
@vstinner I've updated the comments and moved the rest of the capsule-related macros under the |
Ah yes, it seems like we finally reached the root issue! The problem is not "public" vs "private" API. The problem is specific to the "C API capsule". The comment now explains the root issue very well, much better than my first attempt. |
I removed "A future refactoring that obviates the need for _PY_DATETIME_IMPL would be welcome if it could be done in a backwards-compatible way." from the commit message. There is an known option to avoid the define: have 3 header files rather than one. Honestly, I don't think that it's worth it or that it would make the code easier to review. |
Yes, now that it's clear that the stuff under the macro is basically "everything that uses the capsule", it feels much neater to me than when it was "Just remove the unused variable to make gcc happy, and also remove all the macros that Thanks everyone! |
This is a new version of @vstinner's PR #10238. Victor closed it because he was a bit busy to deal with the last minute details, but gave me permission over e-mail to pick it up and run with it.
I think it is a very valuable reorganization and I think it is the last include file that still has
PY_BUILD_CORE
.This is the only change I have made since PR #10238:
I have also pre-squashed this because the commit message is an important part of it and I don't want that to get lost in a squash merge.
CC @abalkin @tim-one @serhiy-storchaka
https://bugs.python.org/issue35081