virtual void write(const char* a) { PyObject* result = NULL; if (_write_method) { PyObject* decoded = NULL; decoded = PyUnicode_DecodeLatin1(a, strlen(a), ""); if (decoded == NULL) { throw PythonExceptionOccurred(); } result = PyObject_CallFunction(_write_method, "O", decoded); Py_DECREF(decoded); if (! result) { throw PythonExceptionOccurred(); } Py_DECREF(result); } }
virtual void add_pair(const char* a, const char* b) { PyObject* value = PyBytes_FromString(b); if (value) { if (PyDict_SetItemString(_dict, a, value)) { Py_DECREF(value); throw PythonExceptionOccurred(); } } Py_DECREF(value); }
virtual void write(const char* a) { PyObject* result = NULL; if (_write_method) { result = PyObject_CallFunction(_write_method, (char *)"s", a); if (! result) { throw PythonExceptionOccurred(); } Py_DECREF(result); } }
virtual void add_pair(const char* a, const char* b) { #if PY_MAJOR_VERSION >= 3 PyObject* value = PyUnicode_FromString(b); #else PyObject* value = PyString_FromString(b); #endif if (value) { if (PyDict_SetItemString(_dict, a, value)) { Py_DECREF(value); throw PythonExceptionOccurred(); } } Py_DECREF(value); }