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: mp+21635@code.launchpad.net

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 (http://www.gnupg.org/documentation/manuals/gpgme/Library-Version-Check.html) 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
1=== modified file 'src/gpgme.c'
2--- src/gpgme.c 2009-04-01 10:05:25 +0000
3+++ src/gpgme.c 2010-05-20 10:44:30 +0000
4@@ -38,6 +38,7 @@
5 static PyObject *
6 create_module(void)
7 {
8+ const char *gpgme_version;
9 PyObject *mod;
10
11 pygpgme_error = PyErr_NewException("gpgme.GpgmeError",
12@@ -88,6 +89,15 @@
13 Py_INCREF(pygpgme_error);
14 PyModule_AddObject(mod, "GpgmeError", pygpgme_error);
15
16+ gpgme_version = gpgme_check_version(NULL);
17+ if (gpgme_version == NULL) {
18+ PyErr_SetString(PyExc_ImportError, "Unable to initialize gpgme.");
19+ Py_DECREF(mod);
20+ return NULL;
21+ }
22+ PyModule_AddObject(mod, "gpgme_version",
23+ PyString_FromString(gpgme_version));
24+
25 return mod;
26 }
27

Subscribers

People subscribed via source and target branches