diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 4c8bef5e0f484ff206f889dc95e2d9d4f9b7b364..560eeb2594073489a17ba494fec40cdd8711f654 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -29,7 +29,7 @@
  * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  *
  * IDENTIFICATION
- *	$Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.28 2003/01/31 22:25:13 tgl Exp $
+ *	$Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.29 2003/01/31 22:35:24 tgl Exp $
  *
  *********************************************************************
  */
@@ -2181,6 +2181,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
 	int			i,
 				rv;
 	PLyPlanObject *plan;
+	char *nulls;
 
 	enter();
 
@@ -2242,6 +2243,8 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
 
 	if (nargs)
 	{
+		nulls = palloc((nargs + 1) * sizeof(char));
+
 		for (i = 0; i < nargs; i++)
 		{
 			PyObject   *elem,
@@ -2249,23 +2252,39 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
 			char	   *sv;
 
 			elem = PySequence_GetItem(list, i);
-			so = PyObject_Str(elem);
-			sv = PyString_AsString(so);
-
-			/*
-			 * FIXME -- if this can elog, we have leak
-			 */
-			plan->values[i] = FunctionCall3(&(plan->args[i].out.d.typfunc),
-											CStringGetDatum(sv),
-						   ObjectIdGetDatum(plan->args[i].out.d.typelem),
-											Int32GetDatum(-1));
-
-			Py_DECREF(so);
-			Py_DECREF(elem);
+			if (elem != Py_None)
+			{
+					so = PyObject_Str(elem);
+					sv = PyString_AsString(so);
+
+					/*
+					 * FIXME -- if this can elog, we have leak
+					 */
+					plan->values[i] = FunctionCall3(&(plan->args[i].out.d.typfunc),
+													CStringGetDatum(sv),
+													ObjectIdGetDatum(plan->args[i].out.d.typelem),
+													Int32GetDatum(-1));
+					
+					Py_DECREF(so);
+					Py_DECREF(elem);
+
+					nulls[i] = ' ';
+			}
+			else
+			{
+				Py_DECREF(elem);
+				plan->values[i] = (Datum) 0;
+				nulls[i] = 'n';
+			}
 		}
+		nulls[i] = '\0';
+	}
+	else
+	{
+		nulls = NULL;
 	}
 
-	rv = SPI_execp(plan->plan, plan->values, NULL, limit);
+	rv = SPI_execp(plan->plan, plan->values, nulls, limit);
 	RESTORE_EXC();
 
 	for (i = 0; i < nargs; i++)