{
struct policy_handle *self = py_talloc_get_ptr(py_self);
char *uuid_str = GUID_string(NULL, &self->uuid);
- PyObject *ret = PyString_FromFormat("policy_handle('%s', %d)", uuid_str, self->handle_type);
+ PyObject *ret = PyString_FromFormat("policy_handle(%d, '%s')", self->handle_type, uuid_str);
+ talloc_free(uuid_str);
+ return ret;
+}
+
+static PyObject *py_policy_handle_str(PyObject *py_self)
+{
+ struct policy_handle *self = py_talloc_get_ptr(py_self);
+ char *uuid_str = GUID_string(NULL, &self->uuid);
+ PyObject *ret = PyString_FromFormat("%d, %s", self->handle_type, uuid_str);
talloc_free(uuid_str);
return ret;
}
{
type->tp_init = py_policy_handle_init;
type->tp_repr = py_policy_handle_repr;
+ type->tp_str = py_policy_handle_str;
}
#define PY_POLICY_HANDLE_PATCH py_policy_handle_patch
text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
class GUIDTests(unittest.TestCase):
+
def test_str(self):
guid = misc.GUID(text1)
self.assertEquals(text1, str(guid))
def test_repr(self):
x = misc.policy_handle(text1, 42)
- self.assertEquals("policy_handle('%s', %d)" % (text1, 42), repr(x))
+ self.assertEquals("policy_handle(%d, '%s')" % (42, text1), repr(x))
+
+ def test_str(self):
+ x = misc.policy_handle(text1, 42)
+ self.assertEquals("%d, %s" % (42, text1), str(x))