Title: PyDateTime_IMPORT() causes compiler warnings
Type: compile error Stage: resolved
Components: None Versions: Python 2.5
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: belopolsky, jackdied, murrayc
Priority: normal Keywords:

Created on 2009-12-09 10:01 by murrayc, last changed 2010-06-12 06:45 by belopolsky. This issue is now closed.

Messages (3)
msg96166 - (view) Author: Murray Cumming (murrayc) Date: 2009-12-09 10:01
At least in Python 2.5 and 2.6 (I haven't checked newer versions), the 
PyDateTime_IMPORT() macro passes string literals to a function that
takes non-const char* parameters:

#define PyDateTime_IMPORT \
        PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import("datetime", \

This makes it impossible to build code with warnings as errors, when
using that macro.
msg99833 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2010-02-22 21:14
changing the definition to (const char *) seems like the right thing to do - a quick grep of the Python source and a search on google codesearch only shows uses with either string literals or string literals cast to (char *) in order to silence a warning.  I tried changing it on the 2.x trunk and it compiles with no warnings.

+1, any other opinions?
msg107201 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-06 18:04
PyCObject is deprecated in 2.7 and removed in 3.x.  PyCapsule_Import() should be used instead of PyCObject_Import() and it already has correct signature:

Include/pycapsule.h:PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block);

Since this is not a bug, I don't think it is appropriate to change it in 2.x.
Date User Action Args
2010-06-12 06:45:02belopolskysetstatus: pending -> closed
2010-06-06 18:04:08belopolskysetstatus: open -> pending
resolution: out of date
messages: + msg107201

stage: needs patch -> resolved
2010-06-06 01:28:14belopolskysetassignee: belopolsky

nosy: + belopolsky
stage: needs patch
2010-02-22 21:14:30jackdiedsetnosy: + jackdied
messages: + msg99833
2009-12-09 10:01:50murrayccreate