summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-04 20:45:34 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-04 20:45:34 -0400
commitb6d83f3c23c11872eb54732d510a0b56a612fde1 (patch)
treeb1d073d1fb94e60be983d99d47e875642ab116b1 /python
parent8029fa4fd429d5ac6610addf78d63aba846ca956 (diff)
downloadfork-ledger-b6d83f3c23c11872eb54732d510a0b56a612fde1.tar.gz
fork-ledger-b6d83f3c23c11872eb54732d510a0b56a612fde1.tar.bz2
fork-ledger-b6d83f3c23c11872eb54732d510a0b56a612fde1.zip
Fixed a long-standing g++ warning.
Diffstat (limited to 'python')
-rw-r--r--python/py_times.cc17
1 files changed, 11 insertions, 6 deletions
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<char *>("datetime"), \
+ const_cast<char *>("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);