-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-35081: Remove Py_BUILD_CORE from datetime.h #10238
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
Changes from 2 commits
2f7832f
1858252
22abaee
8a11d06
a2750c6
69a455d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
*/ | ||
|
||
#include "Python.h" | ||
#include "datetime.h" | ||
#include "structmember.h" | ||
|
||
#include <time.h> | ||
|
@@ -11,14 +12,34 @@ | |
# include <winsock2.h> /* struct timeval */ | ||
#endif | ||
|
||
/* Differentiate between building the core module and building extension | ||
* modules. | ||
*/ | ||
#ifndef Py_BUILD_CORE | ||
#define Py_BUILD_CORE | ||
#endif | ||
#include "datetime.h" | ||
#undef Py_BUILD_CORE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes no difference in this case, but it's somewhat interesting that in the old version, I think this means that if |
||
|
||
#undef PyDate_Check | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#undef PyDate_CheckExact | ||
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) | ||
#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType) | ||
|
||
#undef PyDateTime_Check | ||
#undef PyDateTime_CheckExact | ||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType) | ||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType) | ||
|
||
#undef PyTime_Check | ||
#undef PyTime_CheckExact | ||
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType) | ||
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType) | ||
|
||
#undef PyDelta_Check | ||
#undef PyDelta_CheckExact | ||
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType) | ||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType) | ||
|
||
#undef PyTZInfo_Check | ||
#undef PyTZInfo_CheckExact | ||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType) | ||
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType) | ||
|
||
#undef PyDateTime_TimeZone_UTC | ||
|
||
|
||
/*[clinic input] | ||
module datetime | ||
|
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.
This variable will be created in every compilation unit that includes "datetime.h".
Uh oh!
There was an error while loading. Please reload this page.
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.
Was that already a problem for the C API? this was a pre-existing part of the public API.
At the moment, within CPython, this is only included in
_datetimemodule.c
and_testcapimodule.c
. The latter was, according to Victor, already being compiled withoutPy_BUILD_CORE
.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.
Right, it's a little bit strange to use static here. But my PR doesn't change that, and I don't see how to change the API to avoid it.
@serhiy-storchaka: Would you mind to open a new issue to track this issue?
Uh oh!
There was an error while loading. Please reload this page.
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.
@vstinner I think your PR does change one thing, which is that this static variable is now created even when
Py_BUILD_CORE
is on, right? I don't think that there are any major negative consequences, though, and I don't see a way around it without either changing the public interface or re-introducingPy_BUILD_CORE
to this file, which I gather was the aim of this PR.