diff options
author | Rob Austein <sra@hactrn.net> | 2012-11-08 04:05:26 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-11-08 04:05:26 +0000 |
commit | 1a7b180f631932b5306b1c5a95e289a907ab6881 (patch) | |
tree | 9f3835e778484225fe8bb042f4b73d553f5b728a | |
parent | 6eb4b9936a3cd335befc8144e83d218db1ea5d5e (diff) |
Add __copy__ and __deepcopy__ support to IPAddress objects.
svn path=/branches/tk274/; revision=4812
-rw-r--r-- | rpkid/ext/POW.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rpkid/ext/POW.c b/rpkid/ext/POW.c index 3e74a56a..231b5802 100644 --- a/rpkid/ext/POW.c +++ b/rpkid/ext/POW.c @@ -1346,7 +1346,30 @@ ipaddress_object_number_invert(ipaddress_object *self) return (PyObject *) result; } +static char ipaddress_object_copy__doc__[] = + "" + ; + +static PyObject * +ipaddress_object_copy(ipaddress_object *self, GCC_UNUSED PyObject *args) +{ + ipaddress_object *result = NULL; + + ENTERING(ipaddress_object_copy); + + if ((result = (ipaddress_object *) self->ob_type->tp_alloc(self->ob_type, 0)) == NULL) + goto error; + + memcpy(result->address, self->address, sizeof(result->address)); + result->type = self->type; + + error: + return (PyObject *) result; +} + static struct PyMethodDef ipaddress_object_methods[] = { + Define_Method(__copy__, ipaddress_object_copy, METH_VARARGS), + Define_Method(__deepcopy__, ipaddress_object_copy, METH_VARARGS), Define_Method(toBytes, ipaddress_object_to_bytes, METH_NOARGS), Define_Class_Method(fromBytes, ipaddress_object_from_bytes, METH_VARARGS), {NULL} |