bpo-35081: Remove Py_BUILD_CORE from datetime.h by pganssle · Pull Request #10416 · python/cpython

@vstinner @pganssle

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 <vstinner@redhat.com>