Blob Blame Raw
--- pygpgme-0.1/src/pygpgme-context.c~  2008-11-06 15:33:57.000000000 +0100
+++ pygpgme-0.1/src/pygpgme-context.c   2008-11-06 15:35:35.000000000 +0100
@@ -468,25 +468,29 @@
                           &py_plain, &py_cipher))
         return NULL;
 
-    py_recp = PySequence_Fast(py_recp, "first argument must be a sequence");
-    if (py_recp == NULL)
-        return NULL;
+    if (py_recp == Py_None)
+        recp = NULL;
+    else {
+        py_recp = PySequence_Fast(py_recp, "first argument must be a sequence");
+        if (py_recp == NULL)
+            return NULL;
 
-    length = PySequence_Fast_GET_SIZE(py_recp);
-    recp = malloc((length + 1) * sizeof (gpgme_key_t));
-    for (i = 0; i < length; i++) {
-        PyObject *item = PySequence_Fast_GET_ITEM(py_recp, i);
+        length = PySequence_Fast_GET_SIZE(py_recp);
+        recp = malloc((length + 1) * sizeof (gpgme_key_t));
+        for (i = 0; i < length; i++) {
+            PyObject *item = PySequence_Fast_GET_ITEM(py_recp, i);
 
-        if (!PyObject_TypeCheck(item, &PyGpgmeKey_Type)) {
-            free(recp);
-            Py_DECREF(py_recp);
-            PyErr_SetString(PyExc_TypeError, "items in first argument must "
-                            "be gpgme.Key objects");
-            return NULL;
+            if (!PyObject_TypeCheck(item, &PyGpgmeKey_Type)) {
+                free(recp);
+                Py_DECREF(py_recp);
+                PyErr_SetString(PyExc_TypeError, "items in first argument must "
+                                "be gpgme.Key objects");
+                return NULL;
+            }
+            recp[i] = ((PyGpgmeKey *)item)->key;
         }
-        recp[i] = ((PyGpgmeKey *)item)->key;
+        recp[i] = NULL;
     }
-    recp[i] = NULL;
 
     if (pygpgme_data_new(&plain, py_plain)) {
         free(recp);