3554bd6
diff -up open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c~ open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c
3554bd6
--- open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c~	2009-02-12 15:30:52.000000000 +0100
3554bd6
+++ open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c	2009-02-12 15:48:30.000000000 +0100
3554bd6
@@ -485,19 +485,28 @@ static PyObject *pylibiscsi_discover_sen
3554bd6
 	char *kwlist[] = {"address", "port", "authinfo", NULL};
3554bd6
 	const char *address = NULL;
3554bd6
 	int i, nr_found, port = 3260;
3554bd6
-	PyIscsiChapAuthInfo *pyauthinfo = NULL;
3554bd6
+	PyObject *authinfo_arg = NULL;
3554bd6
 	const struct libiscsi_auth_info *authinfo = NULL;
3554bd6
 	struct libiscsi_node *found_nodes;
3554bd6
 	PyObject* found_node_list;
3554bd6
 
3554bd6
-	if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|iO!",
3554bd6
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|iO",
3554bd6
 					kwlist, &address, &port,
3554bd6
-					&PyIscsiChapAuthInfo_Type,
3554bd6
-					&pyauthinfo))
3554bd6
+					&authinfo_arg))
3554bd6
 		return NULL;
3554bd6
 
3554bd6
-	if (pyauthinfo)
3554bd6
-		authinfo = &pyauthinfo->info;
3554bd6
+	if (authinfo_arg) {
3554bd6
+		if (PyObject_IsInstance(authinfo_arg, (PyObject *)
3554bd6
+					       &PyIscsiChapAuthInfo_Type)) {
3554bd6
+			PyIscsiChapAuthInfo *pyauthinfo =
3554bd6
+				(PyIscsiChapAuthInfo *)authinfo_arg;
3554bd6
+			authinfo = &pyauthinfo->info;
3554bd6
+		} else if (authinfo_arg != Py_None) {
3554bd6
+			PyErr_SetString(PyExc_ValueError,
3554bd6
+				"invalid authinfo type");
3554bd6
+			return NULL;
3554bd6
+		}
3554bd6
+	}
3554bd6
 
3554bd6
 	if (libiscsi_discover_sendtargets(context, address, port, authinfo,
3554bd6
 					  &nr_found, &found_nodes)) {