Merge lp:~jelmer/pygpgme/bug452194 into lp:pygpgme

Proposed by Jelmer Vernooij
Status: Merged
Approved by: James Henstridge
Approved revision: 70
Merged at revision: 69
Proposed branch: lp:~jelmer/pygpgme/bug452194
Merge into: lp:pygpgme
Diff against target: 26 lines (+10/-0)
1 file modified
src/gpgme.c (+10/-0)
To merge this branch: bzr merge lp:~jelmer/pygpgme/bug452194
Reviewer Review Type Date Requested Status
James Henstridge Approve
Review via email:

Commit message

Initialize GPGME properly by calling gpgme_check_version().

Description of the change

This adds a call to gpgme_check_version() to PyGPGME. Without this, all functions in PyGPGME modules built against newer versions of GPGME fail with GPG_ERR_NOT_OPERATIONAL.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks reasonable to me but I don't know anything about gpgme :-)

Revision history for this message
James Henstridge (jamesh) wrote :

Looks pretty good. A few questions:

1. The documentation ( says this method can fail and return NULL. Please add a check for that.

2. Could you change the variable to lower case?

review: Needs Fixing
lp:~jelmer/pygpgme/bug452194 updated
70. By Jelmer Vernooij

Rename GPGME_VERSION -> gpgme_version, raise exception if initializing gpgme fails.

Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/gpgme.c'
--- src/gpgme.c 2009-04-01 10:05:25 +0000
+++ src/gpgme.c 2010-05-20 10:44:30 +0000
@@ -38,6 +38,7 @@
38static PyObject *38static PyObject *
41 const char *gpgme_version;
41 PyObject *mod;42 PyObject *mod;
43 pygpgme_error = PyErr_NewException("gpgme.GpgmeError",44 pygpgme_error = PyErr_NewException("gpgme.GpgmeError",
@@ -88,6 +89,15 @@
88 Py_INCREF(pygpgme_error);89 Py_INCREF(pygpgme_error);
89 PyModule_AddObject(mod, "GpgmeError", pygpgme_error);90 PyModule_AddObject(mod, "GpgmeError", pygpgme_error);
92 gpgme_version = gpgme_check_version(NULL);
93 if (gpgme_version == NULL) {
94 PyErr_SetString(PyExc_ImportError, "Unable to initialize gpgme.");
95 Py_DECREF(mod);
96 return NULL;
97 }
98 PyModule_AddObject(mod, "gpgme_version",
99 PyString_FromString(gpgme_version));
91 return mod;101 return mod;


People subscribed via source and target branches