mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
support unicode keys in dict2attr
This commit is contained in:
parent
38a169e56e
commit
ab451cbee2
@ -35,7 +35,6 @@
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
static mapnik::attributes dict2attr(boost::python::dict const& d)
|
||||
@ -46,7 +45,26 @@ namespace mapnik {
|
||||
boost::python::list keys=d.keys();
|
||||
for (int i=0; i < len(keys); ++i)
|
||||
{
|
||||
std::string key = extract<std::string>(keys[i]);
|
||||
std::string key;
|
||||
object obj_key = keys[i];
|
||||
if (PyUnicode_Check(obj_key.ptr()))
|
||||
{
|
||||
PyObject* temp = PyUnicode_AsUTF8String(obj_key.ptr());
|
||||
if (temp)
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
char* c_str = PyBytes_AsString(temp);
|
||||
#else
|
||||
char* c_str = PyString_AsString(temp);
|
||||
#endif
|
||||
key = c_str;
|
||||
Py_DecRef(temp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
key = extract<std::string>(keys[i]);
|
||||
}
|
||||
object obj = d[key];
|
||||
if (PyUnicode_Check(obj.ptr()))
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user