From b6d83f3c23c11872eb54732d510a0b56a612fde1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 4 Feb 2009 20:45:34 -0400 Subject: Fixed a long-standing g++ warning. --- python/py_times.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'python') diff --git a/python/py_times.cc b/python/py_times.cc index 6beafe39..9e6c4339 100644 --- a/python/py_times.cc +++ b/python/py_times.cc @@ -42,11 +42,16 @@ using namespace boost::python; typedef boost::gregorian::date date; +#define MY_PyDateTime_IMPORT \ + PyDateTimeAPI = (PyDateTime_CAPI*) \ + PyCObject_Import(const_cast("datetime"), \ + const_cast("datetime_CAPI")) + struct date_to_python { static PyObject* convert(const date& dte) { - PyDateTime_IMPORT; + MY_PyDateTime_IMPORT; return PyDate_FromDate(dte.year(), dte.month(), dte.day()); } }; @@ -55,14 +60,14 @@ struct date_from_python { static void* convertible(PyObject* obj_ptr) { - PyDateTime_IMPORT; + MY_PyDateTime_IMPORT; if (PyDate_Check(obj_ptr)) return obj_ptr; return 0; } static void construct(PyObject* obj_ptr, converter::rvalue_from_python_stage1_data* data) { - PyDateTime_IMPORT; + MY_PyDateTime_IMPORT; int y = PyDateTime_GET_YEAR(obj_ptr); int m = PyDateTime_GET_MONTH(obj_ptr); int d = PyDateTime_GET_DAY(obj_ptr); @@ -79,7 +84,7 @@ struct datetime_to_python { static PyObject* convert(const datetime_t& moment) { - PyDateTime_IMPORT; + MY_PyDateTime_IMPORT; date dte = moment.date(); datetime_t::time_duration_type tod = moment.time_of_day(); return PyDateTime_FromDateAndTime(dte.year(), dte.month(), dte.day(), @@ -92,14 +97,14 @@ struct datetime_from_python { static void* convertible(PyObject* obj_ptr) { - PyDateTime_IMPORT; + MY_PyDateTime_IMPORT; if(PyDateTime_Check(obj_ptr)) return obj_ptr; return 0; } static void construct(PyObject* obj_ptr, converter::rvalue_from_python_stage1_data* data) { - PyDateTime_IMPORT; + MY_PyDateTime_IMPORT; int y = PyDateTime_GET_YEAR(obj_ptr); int m = PyDateTime_GET_MONTH(obj_ptr); int d = PyDateTime_GET_DAY(obj_ptr); -- cgit v1.2.3