* Convert a Python unicode object to a C string in PostgreSQL server * encoding. No Python object reference is passed out of this * function. The result is palloc'ed. * * Note that this function is disguised as PyString_AsString() when * using Python 3. That function returns a pointer into the internal * memory of the argument, which isn't exactly the interface of this * function. But i
| 86 | * reference that you ought to better leave alone. |
| 87 | */ |
| 88 | char * |
| 89 | PLyUnicode_AsString(PyObject *unicode) |
| 90 | { |
| 91 | PyObject *o = PLyUnicode_Bytes(unicode); |
| 92 | char *rv = pstrdup(PyBytes_AsString(o)); |
| 93 | |
| 94 | Py_XDECREF(o); |
| 95 | return rv; |
| 96 | } |
| 97 | |
| 98 | #if PY_MAJOR_VERSION >= 3 |
| 99 | /* |
no test coverage detected