User Tools

Site Tools


programming:python:pyradix_search_all_patch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
programming:python:pyradix_search_all_patch [2008/07/05 20:51] – created crustymonkeyprogramming:python:pyradix_search_all_patch [2008/07/05 21:32] crustymonkey
Line 13: Line 13:
 Usage: Usage:
 <code> <code>
-Radix.search_all_containing(<network>) -> [ <node> , <node> , ...] or None+Radix.search_all_containing(<network>) -> [ <node> , <node> , ... ]
 </code> </code>
 <code python> <code python>
Line 61: Line 61:
 Here is the code for the patch, followed by a link to the file. Here is the code for the patch, followed by a link to the file.
 <code> <code>
---- radix_python.c  2008-07-05 15:22:55.000000000 -0500 +--- radix_python.c  2008-07-05 16:25:24.000000000 -0500 
-+++ radix_python.c.new  2008-07-05 15:19:03.000000000 -0500 ++++ radix_python.c.new  2008-07-05 16:15:39.000000000 -0500 
-@@ -453,6 +453,53 @@+@@ -453,6 +453,52 @@
     return (PyObject *)node_obj;     return (PyObject *)node_obj;
  }  }
Line 89: Line 89:
 +   long prefixlen = -1; +   long prefixlen = -1;
 +   int packlen = -1; +   int packlen = -1;
 ++   node_list = PyList_New(0);
 + +
 +   if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|sls#:search_best", keywords, +   if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|sls#:search_best", keywords,
Line 99: Line 100:
 +       node->data == NULL) { +       node->data == NULL) {
 +       Deref_Prefix(prefix); +       Deref_Prefix(prefix);
-+       Py_INCREF(Py_None); ++       return node_list;
-+       return Py_None;+
 +   } +   }
 +   Deref_Prefix(prefix); +   Deref_Prefix(prefix);
-+   node_list = PyList_New(0); 
 +   node_obj = node->data; +   node_obj = node->data;
 +   PyList_Append(node_list , (PyObject *)node_obj); +   PyList_Append(node_list , (PyObject *)node_obj);
Line 117: Line 116:
  "Radix.nodes(prefix) -> List of RadixNode\n\  "Radix.nodes(prefix) -> List of RadixNode\n\
  \n\  \n\
-@@ -640,6 +687,7 @@+@@ -640,6 +686,7 @@
     {"delete",  (PyCFunction)Radix_delete,  METH_VARARGS|METH_KEYWORDS, Radix_delete_doc    },     {"delete",  (PyCFunction)Radix_delete,  METH_VARARGS|METH_KEYWORDS, Radix_delete_doc    },
     {"search_exact",(PyCFunction)Radix_search_exact,METH_VARARGS|METH_KEYWORDS, Radix_search_exact_doc  },     {"search_exact",(PyCFunction)Radix_search_exact,METH_VARARGS|METH_KEYWORDS, Radix_search_exact_doc  },
Line 126: Line 125:
     {"__getstate__",(PyCFunction)Radix_getstate,    METH_VARARGS,           NULL            },     {"__getstate__",(PyCFunction)Radix_getstate,    METH_VARARGS,           NULL            },
 </code> </code>
-The patch file: + 
 +The patch file: {{:programming:python:radix_python.c.patch.gz|}} 
 + 
 +===== Patching ===== 
 +Download the above patch file and do the following: 
 +<code> 
 +# cp radix_python.c.patch.gz /path/to/untarred/py-radix/source/directory 
 +# cd /path/to/untarred/py-radix/source/directory 
 +# gunzip radix_python.c.patch.gz 
 +# patch -p0 radix_python.c < radix_python.c.patch 
 +# python setup.py install 
 +</code> 
 +The last line there will install the patched module. 
programming/python/pyradix_search_all_patch.txt · Last modified: 2008/07/05 22:10 by crustymonkey