mercurial/parsers.c
changeset 16699 d947e1da1259
parent 16665 e410be860393
parent 16679 2950d186a927
child 16732 277e2acb7e5c
--- a/mercurial/parsers.c	Sun May 13 11:47:55 2012 +0200
+++ b/mercurial/parsers.c	Sun May 13 12:52:24 2012 +0200
@@ -785,7 +785,7 @@
 	if (PyInt_Check(value))
 		return index_get(self, PyInt_AS_LONG(value));
 
-	if (PyString_AsStringAndSize(value, &node, &nodelen) == -1)
+	if (node_check(value, &node, &nodelen) == -1)
 		return NULL;
 	rev = index_find_node(self, node, nodelen);
 	if (rev >= -1)
@@ -868,12 +868,15 @@
 
 static PyObject *index_m_get(indexObject *self, PyObject *args)
 {
+	Py_ssize_t nodelen;
+	PyObject *val;
 	char *node;
-	int nodelen, rev;
+	int rev;
 
-	if (!PyArg_ParseTuple(args, "s#", &node, &nodelen))
+	if (!PyArg_ParseTuple(args, "O", &val))
 		return NULL;
-
+	if (node_check(val, &node, &nodelen) == -1)
+		return NULL;
 	rev = index_find_node(self, node, nodelen);
 	if (rev ==  -3)
 		return NULL;
@@ -892,11 +895,8 @@
 		return rev >= -1 && rev < index_length(self);
 	}
 
-	if (!PyString_Check(value))
-		return 0;
-
-	node = PyString_AS_STRING(value);
-	nodelen = PyString_GET_SIZE(value);
+	if (node_check(value, &node, &nodelen) == -1)
+		return -1;
 
 	switch (index_find_node(self, node, nodelen)) {
 	case -3: