From 7cc4f345cf668d117320dc76fe008ffb2bb7943e Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 4 Apr 2011 04:40:18 +0000 Subject: [PATCH] avoid deprecated string conversion warning in pycairo by overriding Pycairo_Import macro and casting away const to please the c/c++ borderlands --- bindings/python/mapnik_python.cpp | 18 ++++++++++-------- bindings/python/python_cairo.cpp | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 536de0d4c..b1d8c7b31 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -295,14 +295,16 @@ bool has_cairo() bool has_pycairo() { #if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) - Pycairo_IMPORT; - /*! - Case where pycairo support has been compiled into - mapnik but at runtime the cairo python module - is unable to be imported and therefore Pycairo surfaces - and contexts cannot be passed to mapnik.render() - */ - if (Pycairo_CAPI == NULL) return false; + Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast("cairo"), const_cast("CAPI")); + if (Pycairo_CAPI == NULL){ + /* + Case where pycairo support has been compiled into + mapnik but at runtime the cairo python module + is unable to be imported and therefore Pycairo surfaces + and contexts cannot be passed to mapnik.render() + */ + return false; + } return true; #else return false; diff --git a/bindings/python/python_cairo.cpp b/bindings/python/python_cairo.cpp index d278a6228..e5420c1b1 100644 --- a/bindings/python/python_cairo.cpp +++ b/bindings/python/python_cairo.cpp @@ -56,8 +56,7 @@ static void *extract_context(PyObject* op) void register_cairo() { - Pycairo_IMPORT; - + Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast("cairo"), const_cast("CAPI")); if (Pycairo_CAPI == NULL) return; boost::python::converter::registry::insert(&extract_surface, boost::python::type_id());