fboudra commented on code in PR #51374:
URL: https://github.com/apache/arrow/pull/51374#discussion_r4433457247


##########
python/pyarrow/src/arrow/python/datetime.h:
##########
@@ -38,7 +39,79 @@
 #  include "datetime.h"
 #else
 #  define PyDateTimeAPI ::arrow::py::internal::datetime_api
-#endif
+
+// Under Py_LIMITED_API (the cp311-abi3 build) CPython's <datetime.h> is
+// entirely absent (it lives behind #ifndef Py_LIMITED_API), so neither the
+// PyDateTime_CAPI struct nor the PyDate_Check / PyDate_FromDate macros are
+// provided. The datetime C-API is still exposed at runtime through the
+// "datetime.datetime_CAPI" capsule (which InitDatetime() imports and stores in
+// datetime_api); the struct layout is a documented, stable part of that
+// capsule contract. Define the struct and the check/constructor macros we use

Review Comment:
   you're right. I reworded the comment:
   ```
   // Under Py_LIMITED_API, CPython's <datetime.h> is #ifdef'd out entirely, so
   // we define the PyDateTime_CAPI struct and the check/constructor macros we
   // use ourselves. The C-API itself is still available at runtime through the
   // "datetime.datetime_CAPI" capsule (imported by InitDatetime). CPython calls
   // this struct "private and subject to change"; it has been append-only since
   // 3.3 and is identical across 3.11.0-3.14.0. We only read fields that exist
   // in 3.11, and InitDatetime checks the capsule version, so drift fails
   // loudly instead of corrupting silently.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to