summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a58acdc)
The solution is not clear.
TODO: A better understanding of what to do is necessary
Do we need a separate treatment for string (maybe with bad encoding?) and other types of PyObject
Do we need str() or repr() and what are the possible causes of failure of str() ?
{
PyObject *s;
PyGILState_STATE gstate = PyGILState_Ensure();
{
PyObject *s;
PyGILState_STATE gstate = PyGILState_Ensure();
- //s=PyObject_Repr(ob);
- s=PyObject_ASCII(ob);
+ // TODO: separate treatment for string (maybe with bad encoding?) and other types of PyObject ?
+ // Do we need str() or repr() and what are the possible causes of failure of str() ?
+ // not clear, needs more analysis.
+ s=PyObject_Str(ob);
+ if (s == NULL) // for instance string with bad encoding, non utf-8
+ {
+ s=PyObject_ASCII(ob); // escape non ASCII characters and like repr(), which is not the same as str()...
+ }
Py_ssize_t size;
char* characters=PyUnicode_AsUTF8AndSize(s, &size);
std::string ss( characters, size);
Py_ssize_t size;
char* characters=PyUnicode_AsUTF8AndSize(s, &size);
std::string ss( characters, size);
#include <unistd.h>
#endif
#include <unistd.h>
#endif
#include "YacsTrace.hxx"
using namespace YACS::ENGINE;
#include "YacsTrace.hxx"
using namespace YACS::ENGINE;
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
+ DEBTRACE("str = " << str);
CPPUNIT_ASSERT_EQUAL(str, string("True"));
delete p;
}
CPPUNIT_ASSERT_EQUAL(str, string("True"));
delete p;
}
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
+ DEBTRACE("str = " << str);
CPPUNIT_ASSERT_EQUAL(str, string("True"));
delete p;
}
CPPUNIT_ASSERT_EQUAL(str, string("True"));
delete p;
}
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
+ DEBTRACE("str = " << str);
CPPUNIT_ASSERT_EQUAL(str, string("True"));
delete p;
}
CPPUNIT_ASSERT_EQUAL(str, string("True"));
delete p;
}
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
YACS::ENGINE::Node* node = p->nodeMap[string("PyGetRes")];
YACS::ENGINE::OutputPort* outputPort = node->getOutputPort(string("res"));
string str = outputPort->getAsString();
+ DEBTRACE("str = " << str);
CPPUNIT_ASSERT_EQUAL(str, string("None"));
delete p;
}
CPPUNIT_ASSERT_EQUAL(str, string("None"));
delete p;
}