Commit c936e6b9 authored by Samuel Debionne's avatar Samuel Debionne

Merge branch '77-sip-python3-__repr__-must-return-unicode-and-not-bytestring' into 'master'

missing Python.h for getting the right version

Closes #77

See merge request !93
parents 413783e2 063abbff
Pipeline #5844 passed with stages
in 10 minutes and 15 seconds
......@@ -679,13 +679,22 @@ void limacore_import_array();
%End
%UnitCode
#include <Python.h>
#if PY_MAJOR_VERSION >= 3
#ifndef LIMA_REPR_CODE
#define LIMA_REPR_CODE \
std::ostringstream str; \
str << *sipCpp; \
const std::string& tmpString = str.str(); \
sipRes = PyUnicode_FromString(tmpString.c_str());
#else
#define LIMA_REPR_CODE \
std::ostringstream str; \
str << *sipCpp; \
const std::string& tmpString = str.str(); \
sipRes = PyString_FromString(tmpString.c_str());
#endif
#endif
%End
%PostInitialisationCode
......
......@@ -37,13 +37,22 @@ void lima@NAME@_import_array();
%UnitCode
#include <Python.h>
#ifndef LIMA_REPR_CODE
#if PY_MAJOR_VERSION >= 3
#define LIMA_REPR_CODE \
std::ostringstream str; \
str << *sipCpp; \
const std::string& tmpString = str.str(); \
sipRes = PyUnicode_FromString(tmpString.c_str());
#else
#define LIMA_REPR_CODE \
std::ostringstream str; \
str << *sipCpp; \
const std::string& tmpString = str.str(); \
sipRes = PyString_FromString(tmpString.c_str());
#endif
#endif
%End
%PostInitialisationCode
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment