We no longer need Samba to be py2/py3 compatible so we choose to return to the standard
function names.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
static PyTypeObject PyLdbBytesType;
#if PY_MAJOR_VERSION >= 3
-#define PyStr_FromFormat PyUnicode_FromFormat
#define PyStr_FromFormatV PyUnicode_FromFormatV
#define PyStr_AsUTF8 PyUnicode_AsUTF8
#define PyStr_AsUTF8AndSize PyUnicode_AsUTF8AndSize
return result;
}
#else
-#define PyStr_FromFormat PyString_FromFormat
#define PyStr_FromFormatV PyString_FromFormatV
#define PyStr_AsUTF8 PyString_AsString
#define PyLdbBytes_FromStringAndSize PyString_FromStringAndSize
Py_DECREF(str);
return NULL;
}
- result = PyStr_FromFormat("Dn(%s)", PyStr_AsUTF8(repr));
+ result = PyUnicode_FromFormat("Dn(%s)", PyStr_AsUTF8(repr));
Py_DECREF(str);
Py_DECREF(repr);
return result;
static PyObject *py_ldb_module_repr(PyLdbModuleObject *self)
{
- return PyStr_FromFormat("<ldb module '%s'>",
+ return PyUnicode_FromFormat("<ldb module '%s'>",
pyldb_Module_AsModule(self)->ops->name);
}
}
if (element_str != NULL) {
- ret = PyStr_FromFormat("MessageElement([%s])", element_str);
+ ret = PyUnicode_FromFormat("MessageElement([%s])", element_str);
talloc_free(element_str);
} else {
ret = PyUnicode_FromString("MessageElement([])");
Py_DECREF(dict);
return NULL;
}
- ret = PyStr_FromFormat("Message(%s)", PyStr_AsUTF8(repr));
+ ret = PyUnicode_FromFormat("Message(%s)", PyStr_AsUTF8(repr));
Py_DECREF(repr);
Py_DECREF(dict);
return ret;
static PyTypeObject TallocObject_Type;
-#if PY_MAJOR_VERSION >= 3
-#define PyStr_FromFormat PyUnicode_FromFormat
-#else
-#define PyStr_FromFormat PyString_FromFormat
-#endif
-
/* print a talloc tree report for a talloc python object */
static PyObject *pytalloc_report_full(PyObject *self, PyObject *args)
{
pytalloc_Object *talloc_obj = (pytalloc_Object *)obj;
PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj);
- return PyStr_FromFormat("<%s talloc object at %p>",
+ return PyUnicode_FromFormat("<%s talloc object at %p>",
type->tp_name, talloc_obj->ptr);
}
pytalloc_BaseObject *talloc_obj = (pytalloc_BaseObject *)obj;
PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj);
- return PyStr_FromFormat("<%s talloc based object at %p>",
+ return PyUnicode_FromFormat("<%s talloc based object at %p>",
type->tp_name, talloc_obj->ptr);
}
#include <tdb.h>
#if PY_MAJOR_VERSION >= 3
-#define PyStr_FromFormat PyUnicode_FromFormat
#define PyInt_FromLong PyLong_FromLong
#define PyInt_Check PyLong_Check
#define PyInt_AsLong PyLong_AsLong
#define Py_TPFLAGS_HAVE_ITER 0
-#else
-#define PyStr_FromFormat PyString_FromFormat
#endif
/* discard signature of 'func' in favour of 'target_sig' */
if (tdb_get_flags(self->ctx) & TDB_INTERNAL) {
return PyUnicode_FromString("Tdb(<internal>)");
} else {
- return PyStr_FromFormat("Tdb('%s')", tdb_name(self->ctx));
+ return PyUnicode_FromFormat("Tdb('%s')", tdb_name(self->ctx));
}
}
/* Strings */
-#define PyStr_FromFormat PyUnicode_FromFormat
#define PyStr_FromFormatV PyUnicode_FromFormatV
#define PyStr_AsString PyUnicode_AsUTF8
const char *empty = "lsaString(None)";
ret = PyUnicode_FromString(empty);
} else {
- ret = PyStr_FromFormat("lsaString('%s')", self->string);
+ ret = PyUnicode_FromFormat("lsaString('%s')", self->string);
}
return ret;
}
{
struct GUID *self = pytalloc_get_ptr(py_self);
char *str = GUID_string(NULL, self);
- PyObject *ret = PyStr_FromFormat("GUID('%s')", str);
+ PyObject *ret = PyUnicode_FromFormat("GUID('%s')", str);
talloc_free(str);
return ret;
}
{
struct policy_handle *self = pytalloc_get_ptr(py_self);
char *uuid_str = GUID_string(NULL, &self->uuid);
- PyObject *ret = PyStr_FromFormat("policy_handle(%d, '%s')", self->handle_type, uuid_str);
+ PyObject *ret = PyUnicode_FromFormat("policy_handle(%d, '%s')", self->handle_type, uuid_str);
talloc_free(uuid_str);
return ret;
}
{
struct policy_handle *self = pytalloc_get_ptr(py_self);
char *uuid_str = GUID_string(NULL, &self->uuid);
- PyObject *ret = PyStr_FromFormat("%d, %s", self->handle_type, uuid_str);
+ PyObject *ret = PyUnicode_FromFormat("%d, %s", self->handle_type, uuid_str);
talloc_free(uuid_str);
return ret;
}
{
struct dom_sid *self = pytalloc_get_ptr(py_self);
struct dom_sid_buf buf;
- PyObject *ret = PyStr_FromFormat(
+ PyObject *ret = PyUnicode_FromFormat(
"dom_sid('%s')", dom_sid_str_buf(self, &buf));
return ret;
}
/* construct and return the right type of python object */
switch (parm->type) {
case P_CHAR:
- return PyStr_FromFormat("%c", *(char *)parm_ptr);
+ return PyUnicode_FromFormat("%c", *(char *)parm_ptr);
case P_STRING:
case P_USTRING:
return PyUnicode_FromString(*(char **)parm_ptr);
static PyObject *py_samdb_url(PyObject *self, PyObject *unused)
{
struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self);
- return PyStr_FromFormat("tdb://%s/sam.ldb", lpcfg_private_dir(lp_ctx));
+ return PyUnicode_FromFormat("tdb://%s/sam.ldb", lpcfg_private_dir(lp_ctx));
}
static PyObject *py_cache_path(PyObject *self, PyObject *args)