classification
Title: Building _testcapimodule as a builtin results in compile error
Type: compile error Stage: resolved
Components: Build Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alanh, iritkatriel, vstinner
Priority: normal Keywords:

Created on 2013-10-22 11:54 by alanh, last changed 2021-04-27 20:46 by vstinner. This issue is now closed.

Messages (4)
msg200926 - (view) Author: Alan Hourihane (alanh) Date: 2013-10-22 11:54
When building _testcapimodule.c as a builtin module, the build fails with this error because it doesn't take into account Py_BUILD_CORE from datetime.h.

m68k-atari-mint-gcc -I. -IInclude -I/j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Include  -I/usr/include -fno-strict-aliasing -O2 -pipe -fwrapv -DNDEBUG    -DPy_BUILD_CORE  -c /j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Modules/_testcapimodule.c -o Modules/_testcapimodule.o
/j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Modules/_testcapimodule.c: In function 'test_datetime_capi':
/j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Modules/_testcapimodule.c:1281:9: error: 'PyDateTimeAPI' undeclared (first use in this function)
/j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Modules/_testcapimodule.c:1281:9: note: each undeclared identifier is reported only once for each function it appears in
/j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Modules/_testcapimodule.c:1293:5: error: 'PyDateTime_IMPORT' undeclared (first use in this function)
/j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Modules/_testcapimodule.c: In function 'test_string_from_format':
/j/var/tmp/portage/dev-lang/python-2.7.5-r2/work/Python-2.7.5/Modules/_testcapimodule.c:1444:5: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'int' [-Wformat]
make: *** [Modules/_testcapimodule.o] Error 1

I fixed it by adding this around the datetime.h include in _testcapimodule.c but not sure if this is correct....

/* Differentiate between building the core module and building extension
 * modules.
 */
#ifdef Py_BUILD_CORE
#undef Py_BUILD_CORE
#include "datetime.h"
#define Py_BUILD_CORE
#else
#include "datetime.h"
#endif
msg207742 - (view) Author: Alan Hourihane (alanh) Date: 2014-01-09 15:34
Anyone ?
msg392107 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-04-27 17:22
I think this was fixed by https://github.com/python/cpython/commit/5c75f37d473140f0e0b7d9bf3a8c08343447ded1

which added "#undef Py_BUILD_CORE_MODULE" to _testcapimodule.c.
msg392130 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-27 20:46
The C API was deeply reworked since 2013. This issue was reported in Python 2.7. I'm confident that it has been fixed in the meanwhile.
History
Date User Action Args
2021-04-27 20:46:45vstinnersetstatus: pending -> closed
resolution: out of date -> fixed
messages: + msg392130

stage: resolved
2021-04-27 17:22:26iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg392107

resolution: out of date
2018-12-11 22:53:24serhiy.storchakasetnosy: + vstinner
2014-06-20 15:56:19zach.waresetresolution: remind -> (no value)
versions: + Python 3.4, Python 3.5
2014-01-09 15:34:11alanhsetresolution: remind
messages: + msg207742
2013-10-22 11:54:06alanhcreate