Issue 7463: PyDateTime_IMPORT() causes compiler warnings (original) (raw)

Issue7463

Created on 2009-12-09 10:01 by murrayc, last changed 2022-04-11 14:56 by admin. 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", \ "datetime_CAPI") 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.
History
Date User Action Args
2022-04-11 14:56:55 admin set github: 51712
2010-06-12 06:45:02 belopolsky set status: pending -> closed
2010-06-06 18:04:08 belopolsky set status: open -> pendingresolution: out of datemessages: + stage: needs patch -> resolved
2010-06-06 01:28:14 belopolsky set assignee: belopolskynosy: + belopolskystage: needs patch
2010-02-22 21:14:30 jackdied set nosy: + jackdiedmessages: +
2009-12-09 10:01:50 murrayc create