Main Page
Namespaces
Namespace List
Namespace Members
All
_
a
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Functions
_
a
c
d
e
f
g
h
m
o
p
r
s
t
u
w
Variables
Typedefs
Classes
Class List
Class Hierarchy
Class Members
All
_
c
d
f
g
i
m
p
r
s
t
~
Functions
_
c
d
g
i
p
r
s
t
~
Variables
Typedefs
Files
File List
File Members
All
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
v
Functions
Variables
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
v
Typedefs
Macros
src
dynamic_graph
python-compat.cc
Go to the documentation of this file.
1
#include "
dynamic-graph/python/python-compat.hh
"
2
3
// Get any PyObject and get its str() representation as an std::string
4
std::string
obj_to_str
(PyObject* o) {
5
std::string ret;
6
PyObject* os;
7
#if PY_MAJOR_VERSION >= 3
8
os = PyObject_Str(o);
9
assert(os != NULL);
10
assert(PyUnicode_Check(os));
11
ret = PyUnicode_AsUTF8(os);
12
#else
13
os = PyObject_Unicode(o);
14
assert(os != NULL);
15
assert(PyUnicode_Check(os));
16
PyObject* oss = PyUnicode_AsUTF8String(os);
17
assert(oss != NULL);
18
ret = PyString_AsString(oss);
19
Py_DECREF(oss);
20
#endif
21
Py_DECREF(os);
22
return
ret;
23
}
python-compat.hh
obj_to_str
std::string obj_to_str(PyObject *o)
Definition:
python-compat.cc:4
dynamic-graph-python
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Oct 27 2023 02:16:36