[git] GPGME - branch, master, updated. gpgme-1.6.0-248-g2ff58fc
by Justus Winter
cvs at cvs.gnupg.org
Thu Jul 28 16:52:21 CEST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".
The branch, master has been updated
via 2ff58fcbd5c060dac3a7feec478819d2c5a164ec (commit)
via 2f754440f28e8f81babdf7efa6186edbc8ad99fd (commit)
via b5aa05c3b261c3846ebbcf76e7505cff5459f918 (commit)
via 1d2f22aae668ce136cacd254875e118dc1faa6a2 (commit)
from de69fa496c09386d5e99747670d6887cf52dd09e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2ff58fcbd5c060dac3a7feec478819d2c5a164ec
Author: Justus Winter <justus at g10code.com>
Date: Thu Jul 28 16:29:05 2016 +0200
python: Drop superfluous imports and trim public interface.
* lang/python/pyme/__init__.py: Avoid leaking low-level 'gpgme', make
sure the main module looks nice and tidy, appease pyflakes.
* lang/python/pyme/errors.py: Appease pyflakes.
* lang/python/pyme/util.py: Avoid leaking low-level 'gpgme' into the
module namespace.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/tests/t-keylist.py: Drop superfluous imports.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.
Signed-off-by: Justus Winter <justus at g10code.com>
diff --git a/lang/python/pyme/__init__.py b/lang/python/pyme/__init__.py
index c42f794..f9e12d0 100644
--- a/lang/python/pyme/__init__.py
+++ b/lang/python/pyme/__init__.py
@@ -99,7 +99,24 @@ GPGME documentation: https://www.gnupg.org/documentation/manuals/gpgme/
"""
-__all__ = ['core', 'errors', 'constants', 'util', 'callbacks', 'version']
-
+from . import core
+from . import errors
+from . import constants
+from . import util
+from . import callbacks
+from . import version
from .core import Context
from .core import Data
+
+# Interface hygiene.
+
+# Drop the low-level gpgme that creeps in for some reason.
+gpgme = None
+del gpgme
+
+# This is a white-list of symbols. Any other will alert pyflakes.
+_ = [Context, Data, core, errors, constants, util, callbacks, version]
+del _
+
+__all__ = ["Context", "Data",
+ "core", "errors", "constants", "util", "callbacks", "version"]
diff --git a/lang/python/pyme/errors.py b/lang/python/pyme/errors.py
index 1e6e4ab..9c58207 100644
--- a/lang/python/pyme/errors.py
+++ b/lang/python/pyme/errors.py
@@ -20,6 +20,9 @@ from . import util
util.process_constants('GPG_ERR_', globals())
+# To appease static analysis tools, we define some constants here:
+NO_ERROR = 0
+
class PymeError(Exception):
pass
diff --git a/lang/python/pyme/util.py b/lang/python/pyme/util.py
index ef0bd65..c4c9e18 100644
--- a/lang/python/pyme/util.py
+++ b/lang/python/pyme/util.py
@@ -16,8 +16,6 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from . import gpgme
-
def process_constants(prefix, scope):
"""Called by the constant modules to load up the constants from the C
library starting with PREFIX. Matching constants will be inserted
@@ -25,6 +23,7 @@ def process_constants(prefix, scope):
of inserted constants.
"""
+ from . import gpgme
index = len(prefix)
constants = {identifier[index:]: getattr(gpgme, identifier)
for identifier in dir(gpgme)
diff --git a/lang/python/pyme/version.py.in b/lang/python/pyme/version.py.in
index a8ab0ca..a40e02d 100644
--- a/lang/python/pyme/version.py.in
+++ b/lang/python/pyme/version.py.in
@@ -59,3 +59,6 @@ Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"""
+
+# Interface hygiene. Keep this at the end.
+del gpgme
diff --git a/lang/python/tests/t-keylist.py b/lang/python/tests/t-keylist.py
index 64fec27..fb59321 100755
--- a/lang/python/tests/t-keylist.py
+++ b/lang/python/tests/t-keylist.py
@@ -17,8 +17,6 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
-import sys
-import pyme
from pyme import core, constants
import support
diff --git a/lang/python/tests/t-sig-notation.py b/lang/python/tests/t-sig-notation.py
index cb4a48e..0f77e37 100755
--- a/lang/python/tests/t-sig-notation.py
+++ b/lang/python/tests/t-sig-notation.py
@@ -18,7 +18,7 @@
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
import os
-from pyme import core, constants, errors
+from pyme import core, constants
import support
expected_notations = {
diff --git a/lang/python/tests/t-sign.py b/lang/python/tests/t-sign.py
index 802a32d..e066a29 100755
--- a/lang/python/tests/t-sign.py
+++ b/lang/python/tests/t-sign.py
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
-import sys
import os
import pyme
from pyme import core, constants
diff --git a/lang/python/tests/t-signers.py b/lang/python/tests/t-signers.py
index 15e8011..9d2cbdc 100755
--- a/lang/python/tests/t-signers.py
+++ b/lang/python/tests/t-signers.py
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
-import sys
import pyme
from pyme import core, constants
import support
commit 2f754440f28e8f81babdf7efa6186edbc8ad99fd
Author: Justus Winter <justus at g10code.com>
Date: Thu Jul 28 15:44:38 2016 +0200
python: Rename compiled SWIG module.
Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.
This commit renames the compiled Python module produced by SWIG.
* lang/python/Makefile.am: Rename the compiled Python module.
* lang/python/gpgme.i: Likewise.
* lang/python/pyme/core.py: Likewise.
* lang/python/pyme/errors.py: Likewise.
* lang/python/pyme/util.py: Likewise.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/setup.py.in: Likewise.
Signed-off-by: Justus Winter <justus at g10code.com>
diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 3651db9..f0df800 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -58,7 +58,7 @@ sdist: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
twine upload $^
-CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/pygpgme.py \
+CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/gpgme.py \
copystamp
# Remove the rest.
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index 11af994..dfa3775 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -17,7 +17,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-%module pygpgme
+%module gpgme
%include "cpointer.i"
%include "cstring.i"
diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py
index f5cc69c..50c6c0f 100644
--- a/lang/python/pyme/core.py
+++ b/lang/python/pyme/core.py
@@ -27,7 +27,7 @@ and the 'Data' class describing buffers of data.
import re
import os
import weakref
-from . import pygpgme
+from . import gpgme
from .errors import errorcheck, GPGMEError
from . import constants
from . import errors
@@ -93,9 +93,9 @@ class GpgmeWrapper(object):
_boolean_properties = set()
def __wrap_boolean_property(self, key, do_set=False, value=None):
- get_func = getattr(pygpgme,
+ get_func = getattr(gpgme,
"{}get_{}".format(self._cprefix, key))
- set_func = getattr(pygpgme,
+ set_func = getattr(gpgme,
"{}set_{}".format(self._cprefix, key))
def get(slf):
return bool(get_func(slf.wrapped))
@@ -120,19 +120,19 @@ class GpgmeWrapper(object):
return self.__wrap_boolean_property(key)
name = self._cprefix + key
- func = getattr(pygpgme, name)
+ func = getattr(gpgme, name)
if self._errorcheck(name):
def _funcwrap(slf, *args):
result = func(slf.wrapped, *args)
if slf._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(slf)
+ gpgme.pyme_raise_callback_exception(slf)
return errorcheck(result, "Invocation of " + name)
else:
def _funcwrap(slf, *args):
result = func(slf.wrapped, *args)
if slf._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(slf)
+ gpgme.pyme_raise_callback_exception(slf)
return result
doc = self._munge_docstring.sub(r'\2.\1(\3', getattr(func, "__doc__"))
@@ -186,10 +186,10 @@ class Context(GpgmeWrapper):
if wrapped:
self.own = False
else:
- tmp = pygpgme.new_gpgme_ctx_t_p()
- errorcheck(pygpgme.gpgme_new(tmp))
- wrapped = pygpgme.gpgme_ctx_t_p_value(tmp)
- pygpgme.delete_gpgme_ctx_t_p(tmp)
+ tmp = gpgme.new_gpgme_ctx_t_p()
+ errorcheck(gpgme.gpgme_new(tmp))
+ wrapped = gpgme.gpgme_ctx_t_p_value(tmp)
+ gpgme.delete_gpgme_ctx_t_p(tmp)
self.own = True
super().__init__(wrapped)
self.armor = armor
@@ -497,9 +497,9 @@ class Context(GpgmeWrapper):
else:
cmd = " ".join(util.percent_escape(f) for f in command)
- errptr = pygpgme.new_gpgme_error_t_p()
+ errptr = gpgme.new_gpgme_error_t_p()
- err = pygpgme.gpgme_op_assuan_transact_ext(
+ err = gpgme.gpgme_op_assuan_transact_ext(
self.wrapped,
cmd,
(weakref.ref(self), data_cb) if data_cb else None,
@@ -508,12 +508,12 @@ class Context(GpgmeWrapper):
errptr)
if self._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(self)
+ gpgme.pyme_raise_callback_exception(self)
errorcheck(err)
- status = pygpgme.gpgme_error_t_p_value(errptr)
- pygpgme.delete_gpgme_error_t_p(errptr)
+ status = gpgme.gpgme_error_t_p_value(errptr)
+ gpgme.delete_gpgme_error_t_p(errptr)
return GPGMEError(status) if status != 0 else None
@@ -565,15 +565,15 @@ class Context(GpgmeWrapper):
_boolean_properties = {'armor', 'textmode', 'offline'}
def __del__(self):
- if not pygpgme:
- # At interpreter shutdown, pygpgme is set to NONE.
+ if not gpgme:
+ # At interpreter shutdown, gpgme is set to NONE.
return
self._free_passcb()
self._free_progresscb()
self._free_statuscb()
- if self.own and self.wrapped and pygpgme.gpgme_release:
- pygpgme.gpgme_release(self.wrapped)
+ if self.own and self.wrapped and gpgme.gpgme_release:
+ gpgme.gpgme_release(self.wrapped)
self.wrapped = None
# Implement the context manager protocol.
@@ -594,27 +594,27 @@ class Context(GpgmeWrapper):
"""Returns the next key in the list created
by a call to op_keylist_start(). The object returned
is of type Key."""
- ptr = pygpgme.new_gpgme_key_t_p()
+ ptr = gpgme.new_gpgme_key_t_p()
try:
- errorcheck(pygpgme.gpgme_op_keylist_next(self.wrapped, ptr))
- key = pygpgme.gpgme_key_t_p_value(ptr)
+ errorcheck(gpgme.gpgme_op_keylist_next(self.wrapped, ptr))
+ key = gpgme.gpgme_key_t_p_value(ptr)
except errors.GPGMEError as excp:
key = None
if excp.getcode() != errors.EOF:
raise excp
- pygpgme.delete_gpgme_key_t_p(ptr)
+ gpgme.delete_gpgme_key_t_p(ptr)
if key:
- key.__del__ = lambda self: pygpgme.gpgme_key_unref(self)
+ key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
return key
def get_key(self, fpr, secret):
"""Return the key corresponding to the fingerprint 'fpr'"""
- ptr = pygpgme.new_gpgme_key_t_p()
- errorcheck(pygpgme.gpgme_get_key(self.wrapped, fpr, ptr, secret))
- key = pygpgme.gpgme_key_t_p_value(ptr)
- pygpgme.delete_gpgme_key_t_p(ptr)
+ ptr = gpgme.new_gpgme_key_t_p()
+ errorcheck(gpgme.gpgme_get_key(self.wrapped, fpr, ptr, secret))
+ key = gpgme.gpgme_key_t_p_value(ptr)
+ gpgme.delete_gpgme_key_t_p(ptr)
if key:
- key.__del__ = lambda self: pygpgme.gpgme_key_unref(self)
+ key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
return key
def op_trustlist_all(self, *args, **kwargs):
@@ -629,15 +629,15 @@ class Context(GpgmeWrapper):
"""Returns the next trust item in the list created
by a call to op_trustlist_start(). The object returned
is of type TrustItem."""
- ptr = pygpgme.new_gpgme_trust_item_t_p()
+ ptr = gpgme.new_gpgme_trust_item_t_p()
try:
- errorcheck(pygpgme.gpgme_op_trustlist_next(self.wrapped, ptr))
- trust = pygpgme.gpgme_trust_item_t_p_value(ptr)
+ errorcheck(gpgme.gpgme_op_trustlist_next(self.wrapped, ptr))
+ trust = gpgme.gpgme_trust_item_t_p_value(ptr)
except errors.GPGMEError as excp:
trust = None
if excp.getcode() != errors.EOF:
raise
- pygpgme.delete_gpgme_trust_item_t_p(ptr)
+ gpgme.delete_gpgme_trust_item_t_p(ptr)
return trust
def set_passphrase_cb(self, func, hook=None):
@@ -661,10 +661,10 @@ class Context(GpgmeWrapper):
hookdata = (weakref.ref(self), func)
else:
hookdata = (weakref.ref(self), func, hook)
- pygpgme.pyme_set_passphrase_cb(self, hookdata)
+ gpgme.pyme_set_passphrase_cb(self, hookdata)
def _free_passcb(self):
- if pygpgme.pyme_set_passphrase_cb:
+ if gpgme.pyme_set_passphrase_cb:
self.set_passphrase_cb(None)
def set_progress_cb(self, func, hook=None):
@@ -686,10 +686,10 @@ class Context(GpgmeWrapper):
hookdata = (weakref.ref(self), func)
else:
hookdata = (weakref.ref(self), func, hook)
- pygpgme.pyme_set_progress_cb(self, hookdata)
+ gpgme.pyme_set_progress_cb(self, hookdata)
def _free_progresscb(self):
- if pygpgme.pyme_set_progress_cb:
+ if gpgme.pyme_set_progress_cb:
self.set_progress_cb(None)
def set_status_cb(self, func, hook=None):
@@ -710,10 +710,10 @@ class Context(GpgmeWrapper):
hookdata = (weakref.ref(self), func)
else:
hookdata = (weakref.ref(self), func, hook)
- pygpgme.pyme_set_status_cb(self, hookdata)
+ gpgme.pyme_set_status_cb(self, hookdata)
def _free_statuscb(self):
- if pygpgme.pyme_set_status_cb:
+ if gpgme.pyme_set_status_cb:
self.set_status_cb(None)
@property
@@ -734,7 +734,7 @@ class Context(GpgmeWrapper):
infos -- a list of engine infos
"""
- return pygpgme.gpgme_ctx_get_engine_info(self.wrapped)
+ return gpgme.gpgme_ctx_get_engine_info(self.wrapped)
def set_engine_info(self, proto, file_name=None, home_dir=None):
"""Change engine configuration
@@ -747,7 +747,7 @@ class Context(GpgmeWrapper):
home_dir -- configuration directory (unchanged if None)
"""
- errorcheck(pygpgme.gpgme_ctx_set_engine_info(
+ errorcheck(gpgme.gpgme_ctx_set_engine_info(
self.wrapped, proto, file_name, home_dir))
def wait(self, hang):
@@ -757,10 +757,10 @@ class Context(GpgmeWrapper):
Please read the GPGME manual for more information.
"""
- ptr = pygpgme.new_gpgme_error_t_p()
- pygpgme.gpgme_wait(self.wrapped, ptr, hang)
- status = pygpgme.gpgme_error_t_p_value(ptr)
- pygpgme.delete_gpgme_error_t_p(ptr)
+ ptr = gpgme.new_gpgme_error_t_p()
+ gpgme.gpgme_wait(self.wrapped, ptr, hang)
+ status = gpgme.gpgme_error_t_p_value(ptr)
+ gpgme.delete_gpgme_error_t_p(ptr)
errorcheck(status)
def op_edit(self, key, func, fnc_value, out):
@@ -772,9 +772,9 @@ class Context(GpgmeWrapper):
else:
opaquedata = (weakref.ref(self), func)
- result = pygpgme.gpgme_op_edit(self.wrapped, key, opaquedata, out)
+ result = gpgme.gpgme_op_edit(self.wrapped, key, opaquedata, out)
if self._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(self)
+ gpgme.pyme_raise_callback_exception(self)
errorcheck(result)
class Data(GpgmeWrapper):
@@ -866,14 +866,14 @@ class Data(GpgmeWrapper):
self.new()
def __del__(self):
- if not pygpgme:
- # At interpreter shutdown, pygpgme is set to NONE.
+ if not gpgme:
+ # At interpreter shutdown, gpgme is set to NONE.
return
- if self.wrapped != None and pygpgme.gpgme_data_release:
- pygpgme.gpgme_data_release(self.wrapped)
+ if self.wrapped != None and gpgme.gpgme_data_release:
+ gpgme.gpgme_data_release(self.wrapped)
if self._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(self)
+ gpgme.pyme_raise_callback_exception(self)
self.wrapped = None
self._free_datacbs()
@@ -887,40 +887,40 @@ class Data(GpgmeWrapper):
self._data_cbs = None
def new(self):
- tmp = pygpgme.new_gpgme_data_t_p()
- errorcheck(pygpgme.gpgme_data_new(tmp))
- self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
- pygpgme.delete_gpgme_data_t_p(tmp)
+ tmp = gpgme.new_gpgme_data_t_p()
+ errorcheck(gpgme.gpgme_data_new(tmp))
+ self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
+ gpgme.delete_gpgme_data_t_p(tmp)
def new_from_mem(self, string, copy=True):
- tmp = pygpgme.new_gpgme_data_t_p()
- errorcheck(pygpgme.gpgme_data_new_from_mem(tmp,string,len(string),copy))
- self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
- pygpgme.delete_gpgme_data_t_p(tmp)
+ tmp = gpgme.new_gpgme_data_t_p()
+ errorcheck(gpgme.gpgme_data_new_from_mem(tmp,string,len(string),copy))
+ self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
+ gpgme.delete_gpgme_data_t_p(tmp)
def new_from_file(self, filename, copy=True):
- tmp = pygpgme.new_gpgme_data_t_p()
+ tmp = gpgme.new_gpgme_data_t_p()
try:
- errorcheck(pygpgme.gpgme_data_new_from_file(tmp, filename, copy))
+ errorcheck(gpgme.gpgme_data_new_from_file(tmp, filename, copy))
except errors.GPGMEError as e:
if e.getcode() == errors.INV_VALUE and not copy:
raise ValueError("delayed reads are not yet supported")
else:
raise e
- self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
- pygpgme.delete_gpgme_data_t_p(tmp)
+ self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
+ gpgme.delete_gpgme_data_t_p(tmp)
def new_from_cbs(self, read_cb, write_cb, seek_cb, release_cb, hook=None):
- tmp = pygpgme.new_gpgme_data_t_p()
+ tmp = gpgme.new_gpgme_data_t_p()
if hook != None:
hookdata = (weakref.ref(self),
read_cb, write_cb, seek_cb, release_cb, hook)
else:
hookdata = (weakref.ref(self),
read_cb, write_cb, seek_cb, release_cb)
- pygpgme.pyme_data_new_from_cbs(self, hookdata, tmp)
- self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
- pygpgme.delete_gpgme_data_t_p(tmp)
+ gpgme.pyme_data_new_from_cbs(self, hookdata, tmp)
+ self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
+ gpgme.delete_gpgme_data_t_p(tmp)
def new_from_filepart(self, file, offset, length):
"""This wraps the GPGME gpgme_data_new_from_filepart() function.
@@ -931,22 +931,22 @@ class Data(GpgmeWrapper):
"""
- tmp = pygpgme.new_gpgme_data_t_p()
+ tmp = gpgme.new_gpgme_data_t_p()
filename = None
fp = None
if type(file) == type("x"):
filename = file
else:
- fp = pygpgme.fdopen(file.fileno(), file.mode)
+ fp = gpgme.fdopen(file.fileno(), file.mode)
if fp == None:
raise ValueError("Failed to open file from %s arg %s" % \
(str(type(file)), str(file)))
- errorcheck(pygpgme.gpgme_data_new_from_filepart(tmp, filename, fp,
+ errorcheck(gpgme.gpgme_data_new_from_filepart(tmp, filename, fp,
offset, length))
- self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
- pygpgme.delete_gpgme_data_t_p(tmp)
+ self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
+ gpgme.delete_gpgme_data_t_p(tmp)
def new_from_fd(self, file):
"""This wraps the GPGME gpgme_data_new_from_fd() function. The
@@ -954,10 +954,10 @@ class Data(GpgmeWrapper):
fileno() method.
"""
- tmp = pygpgme.new_gpgme_data_t_p()
- errorcheck(pygpgme.gpgme_data_new_from_fd(tmp, file.fileno()))
- self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
- pygpgme.delete_gpgme_data_t_p(tmp)
+ tmp = gpgme.new_gpgme_data_t_p()
+ errorcheck(gpgme.gpgme_data_new_from_fd(tmp, file.fileno()))
+ self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
+ gpgme.delete_gpgme_data_t_p(tmp)
def new_from_stream(self, file):
"""This wrap around gpgme_data_new_from_stream is an alias for
@@ -969,10 +969,10 @@ class Data(GpgmeWrapper):
"""Write buffer given as string or bytes.
If a string is given, it is implicitly encoded using UTF-8."""
- written = pygpgme.gpgme_data_write(self.wrapped, buffer)
+ written = gpgme.gpgme_data_write(self.wrapped, buffer)
if written < 0:
if self._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(self)
+ gpgme.pyme_raise_callback_exception(self)
else:
raise GPGMEError.fromSyserror()
return written
@@ -990,10 +990,10 @@ class Data(GpgmeWrapper):
if size > 0:
try:
- result = pygpgme.gpgme_data_read(self.wrapped, size)
+ result = gpgme.gpgme_data_read(self.wrapped, size)
except:
if self._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(self)
+ gpgme.pyme_raise_callback_exception(self)
else:
raise
return result
@@ -1001,10 +1001,10 @@ class Data(GpgmeWrapper):
chunks = []
while True:
try:
- result = pygpgme.gpgme_data_read(self.wrapped, 4096)
+ result = gpgme.gpgme_data_read(self.wrapped, 4096)
except:
if self._callback_excinfo:
- pygpgme.pyme_raise_callback_exception(self)
+ gpgme.pyme_raise_callback_exception(self)
else:
raise
if len(result) == 0:
@@ -1013,16 +1013,16 @@ class Data(GpgmeWrapper):
return b''.join(chunks)
def pubkey_algo_name(algo):
- return pygpgme.gpgme_pubkey_algo_name(algo)
+ return gpgme.gpgme_pubkey_algo_name(algo)
def hash_algo_name(algo):
- return pygpgme.gpgme_hash_algo_name(algo)
+ return gpgme.gpgme_hash_algo_name(algo)
def get_protocol_name(proto):
- return pygpgme.gpgme_get_protocol_name(proto)
+ return gpgme.gpgme_get_protocol_name(proto)
def check_version(version=None):
- return pygpgme.gpgme_check_version(version)
+ return gpgme.gpgme_check_version(version)
# check_version also makes sure that several subsystems are properly
# initialized, and it must be run at least once before invoking any
@@ -1032,19 +1032,19 @@ check_version()
def engine_check_version (proto):
try:
- errorcheck(pygpgme.gpgme_engine_check_version(proto))
+ errorcheck(gpgme.gpgme_engine_check_version(proto))
return True
except errors.GPGMEError:
return False
def get_engine_info():
- ptr = pygpgme.new_gpgme_engine_info_t_p()
+ ptr = gpgme.new_gpgme_engine_info_t_p()
try:
- errorcheck(pygpgme.gpgme_get_engine_info(ptr))
- info = pygpgme.gpgme_engine_info_t_p_value(ptr)
+ errorcheck(gpgme.gpgme_get_engine_info(ptr))
+ info = gpgme.gpgme_engine_info_t_p_value(ptr)
except errors.GPGMEError:
info = None
- pygpgme.delete_gpgme_engine_info_t_p(ptr)
+ gpgme.delete_gpgme_engine_info_t_p(ptr)
return info
def set_engine_info(proto, file_name, home_dir=None):
@@ -1053,11 +1053,11 @@ def set_engine_info(proto, file_name, home_dir=None):
the executable program implementing this protocol. 'home_dir' is the
directory name of the configuration directory (engine's default is
used if omitted)."""
- errorcheck(pygpgme.gpgme_set_engine_info(proto, file_name, home_dir))
+ errorcheck(gpgme.gpgme_set_engine_info(proto, file_name, home_dir))
def set_locale(category, value):
"""Sets the default locale used by contexts"""
- errorcheck(pygpgme.gpgme_set_locale(None, category, value))
+ errorcheck(gpgme.gpgme_set_locale(None, category, value))
def wait(hang):
"""Wait for asynchronous call on any Context to finish.
@@ -1068,10 +1068,10 @@ def wait(hang):
context - context which caused this call to return.
Please read the GPGME manual of more information."""
- ptr = pygpgme.new_gpgme_error_t_p()
- context = pygpgme.gpgme_wait(None, ptr, hang)
- status = pygpgme.gpgme_error_t_p_value(ptr)
- pygpgme.delete_gpgme_error_t_p(ptr)
+ ptr = gpgme.new_gpgme_error_t_p()
+ context = gpgme.gpgme_wait(None, ptr, hang)
+ status = gpgme.gpgme_error_t_p_value(ptr)
+ gpgme.delete_gpgme_error_t_p(ptr)
if context == None:
errorcheck(status)
else:
diff --git a/lang/python/pyme/errors.py b/lang/python/pyme/errors.py
index 0194931..1e6e4ab 100644
--- a/lang/python/pyme/errors.py
+++ b/lang/python/pyme/errors.py
@@ -15,7 +15,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from . import pygpgme
+from . import gpgme
from . import util
util.process_constants('GPG_ERR_', globals())
@@ -30,20 +30,20 @@ class GPGMEError(PymeError):
@classmethod
def fromSyserror(cls):
- return cls(pygpgme.gpgme_err_code_from_syserror())
+ return cls(gpgme.gpgme_err_code_from_syserror())
def getstring(self):
- message = "%s: %s" % (pygpgme.gpgme_strsource(self.error),
- pygpgme.gpgme_strerror(self.error))
+ message = "%s: %s" % (gpgme.gpgme_strsource(self.error),
+ gpgme.gpgme_strerror(self.error))
if self.message != None:
message = "%s: %s" % (self.message, message)
return message
def getcode(self):
- return pygpgme.gpgme_err_code(self.error)
+ return gpgme.gpgme_err_code(self.error)
def getsource(self):
- return pygpgme.gpgme_err_source(self.error)
+ return gpgme.gpgme_err_source(self.error)
def __str__(self):
return self.getstring()
@@ -62,7 +62,7 @@ class InvalidRecipients(EncryptionError):
self.recipients = recipients
def __str__(self):
return ", ".join("{}: {}".format(r.fpr,
- pygpgme.gpgme_strerror(r.reason))
+ gpgme.gpgme_strerror(r.reason))
for r in self.recipients)
class DeryptionError(PymeError):
@@ -82,7 +82,7 @@ class InvalidSigners(SigningError):
self.signers = signers
def __str__(self):
return ", ".join("{}: {}".format(s.fpr,
- pygpgme.gpgme_strerror(s.reason))
+ gpgme.gpgme_strerror(s.reason))
for s in self.signers)
class VerificationError(PymeError):
@@ -93,7 +93,7 @@ class BadSignatures(VerificationError):
self.result = result
def __str__(self):
return ", ".join("{}: {}".format(s.fpr,
- pygpgme.gpgme_strerror(s.status))
+ gpgme.gpgme_strerror(s.status))
for s in self.result.signatures
if s.status != NO_ERROR)
diff --git a/lang/python/pyme/util.py b/lang/python/pyme/util.py
index 7eb6353..ef0bd65 100644
--- a/lang/python/pyme/util.py
+++ b/lang/python/pyme/util.py
@@ -16,7 +16,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from . import pygpgme
+from . import gpgme
def process_constants(prefix, scope):
"""Called by the constant modules to load up the constants from the C
@@ -26,8 +26,8 @@ def process_constants(prefix, scope):
"""
index = len(prefix)
- constants = {identifier[index:]: getattr(pygpgme, identifier)
- for identifier in dir(pygpgme)
+ constants = {identifier[index:]: getattr(gpgme, identifier)
+ for identifier in dir(gpgme)
if identifier.startswith(prefix)}
scope.update(constants)
return list(constants.keys())
diff --git a/lang/python/pyme/version.py.in b/lang/python/pyme/version.py.in
index cfa49a2..a8ab0ca 100644
--- a/lang/python/pyme/version.py.in
+++ b/lang/python/pyme/version.py.in
@@ -16,11 +16,11 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from . import pygpgme
+from . import gpgme
productname = 'pyme'
versionstr = "@VERSION@"
-gpgme_versionstr = pygpgme.GPGME_VERSION
+gpgme_versionstr = gpgme.GPGME_VERSION
versionlist = versionstr.split(".")
major = versionlist[0]
diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in
index 373e17c..45b56a3 100755
--- a/lang/python/setup.py.in
+++ b/lang/python/setup.py.in
@@ -135,7 +135,7 @@ class BuildExtFirstHack(build):
self.run_command('build_ext')
build.run(self)
-swige = Extension("pyme._pygpgme", ["gpgme.i", "helpers.c"],
+swige = Extension("pyme._gpgme", ["gpgme.i", "helpers.c"],
swig_opts = ['-py3', '-builtin',
'-outdir', 'pyme'] + extra_swig_opts,
include_dirs = include_dirs,
commit b5aa05c3b261c3846ebbcf76e7505cff5459f918
Author: Justus Winter <justus at g10code.com>
Date: Thu Jul 28 15:24:05 2016 +0200
python: Rename exported functions.
Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.
This commit renames all functions that are exported to the Python
world.
* lang/python/helpers.c: Rename all exported functions.
* lang/python/helpers.h: Likewise.
* lang/python/pyme/core.py: Likewise.
Signed-off-by: Justus Winter <justus at g10code.com>
diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index 27e7274..0406f9f 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -123,7 +123,7 @@ static void _pyme_stash_callback_exception(PyObject *weak_self)
Py_DECREF(excinfo);
}
-PyObject *pygpgme_raise_callback_exception(PyObject *self)
+PyObject *pyme_raise_callback_exception(PyObject *self)
{
PyObject *ptype, *pvalue, *ptraceback, *excinfo;
@@ -413,7 +413,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
}
PyObject *
-pygpgme_set_passphrase_cb(PyObject *self, PyObject *cb) {
+pyme_set_passphrase_cb(PyObject *self, PyObject *cb) {
PyObject *wrapped;
gpgme_ctx_t ctx;
@@ -495,7 +495,7 @@ static void pyProgressCb(void *hook, const char *what, int type, int current,
}
PyObject *
-pygpgme_set_progress_cb(PyObject *self, PyObject *cb) {
+pyme_set_progress_cb(PyObject *self, PyObject *cb) {
PyObject *wrapped;
gpgme_ctx_t ctx;
@@ -592,7 +592,7 @@ static gpgme_error_t pyStatusCb(void *hook, const char *keyword,
}
PyObject *
-pygpgme_set_status_cb(PyObject *self, PyObject *cb) {
+pyme_set_status_cb(PyObject *self, PyObject *cb) {
PyObject *wrapped;
gpgme_ctx_t ctx;
@@ -910,9 +910,9 @@ static void pyDataReleaseCb(void *hook)
}
PyObject *
-pygpgme_data_new_from_cbs(PyObject *self,
- PyObject *pycbs,
- gpgme_data_t *r_data)
+pyme_data_new_from_cbs(PyObject *self,
+ PyObject *pycbs,
+ gpgme_data_t *r_data)
{
static struct gpgme_data_cbs cbs = {
pyDataReadCb,
diff --git a/lang/python/helpers.h b/lang/python/helpers.h
index f41d327..16a9b9f 100644
--- a/lang/python/helpers.h
+++ b/lang/python/helpers.h
@@ -26,11 +26,11 @@
#define write(fd, str, sz) {DWORD written; WriteFile((HANDLE) fd, str, sz, &written, 0);}
#endif
-PyObject *pygpgme_raise_callback_exception(PyObject *self);
+PyObject *pyme_raise_callback_exception(PyObject *self);
-PyObject *pygpgme_set_passphrase_cb(PyObject *self, PyObject *cb);
-PyObject *pygpgme_set_progress_cb(PyObject *self, PyObject *cb);
-PyObject *pygpgme_set_status_cb(PyObject *self, PyObject *cb);
+PyObject *pyme_set_passphrase_cb(PyObject *self, PyObject *cb);
+PyObject *pyme_set_progress_cb(PyObject *self, PyObject *cb);
+PyObject *pyme_set_status_cb(PyObject *self, PyObject *cb);
-PyObject *pygpgme_data_new_from_cbs(PyObject *self, PyObject *pycbs,
- gpgme_data_t *r_data);
+PyObject *pyme_data_new_from_cbs(PyObject *self, PyObject *pycbs,
+ gpgme_data_t *r_data);
diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py
index b25808d..f5cc69c 100644
--- a/lang/python/pyme/core.py
+++ b/lang/python/pyme/core.py
@@ -126,13 +126,13 @@ class GpgmeWrapper(object):
def _funcwrap(slf, *args):
result = func(slf.wrapped, *args)
if slf._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(slf)
+ pygpgme.pyme_raise_callback_exception(slf)
return errorcheck(result, "Invocation of " + name)
else:
def _funcwrap(slf, *args):
result = func(slf.wrapped, *args)
if slf._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(slf)
+ pygpgme.pyme_raise_callback_exception(slf)
return result
doc = self._munge_docstring.sub(r'\2.\1(\3', getattr(func, "__doc__"))
@@ -508,7 +508,7 @@ class Context(GpgmeWrapper):
errptr)
if self._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(self)
+ pygpgme.pyme_raise_callback_exception(self)
errorcheck(err)
@@ -661,10 +661,10 @@ class Context(GpgmeWrapper):
hookdata = (weakref.ref(self), func)
else:
hookdata = (weakref.ref(self), func, hook)
- pygpgme.pygpgme_set_passphrase_cb(self, hookdata)
+ pygpgme.pyme_set_passphrase_cb(self, hookdata)
def _free_passcb(self):
- if pygpgme.pygpgme_set_passphrase_cb:
+ if pygpgme.pyme_set_passphrase_cb:
self.set_passphrase_cb(None)
def set_progress_cb(self, func, hook=None):
@@ -686,10 +686,10 @@ class Context(GpgmeWrapper):
hookdata = (weakref.ref(self), func)
else:
hookdata = (weakref.ref(self), func, hook)
- pygpgme.pygpgme_set_progress_cb(self, hookdata)
+ pygpgme.pyme_set_progress_cb(self, hookdata)
def _free_progresscb(self):
- if pygpgme.pygpgme_set_progress_cb:
+ if pygpgme.pyme_set_progress_cb:
self.set_progress_cb(None)
def set_status_cb(self, func, hook=None):
@@ -710,10 +710,10 @@ class Context(GpgmeWrapper):
hookdata = (weakref.ref(self), func)
else:
hookdata = (weakref.ref(self), func, hook)
- pygpgme.pygpgme_set_status_cb(self, hookdata)
+ pygpgme.pyme_set_status_cb(self, hookdata)
def _free_statuscb(self):
- if pygpgme.pygpgme_set_status_cb:
+ if pygpgme.pyme_set_status_cb:
self.set_status_cb(None)
@property
@@ -774,7 +774,7 @@ class Context(GpgmeWrapper):
result = pygpgme.gpgme_op_edit(self.wrapped, key, opaquedata, out)
if self._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(self)
+ pygpgme.pyme_raise_callback_exception(self)
errorcheck(result)
class Data(GpgmeWrapper):
@@ -873,7 +873,7 @@ class Data(GpgmeWrapper):
if self.wrapped != None and pygpgme.gpgme_data_release:
pygpgme.gpgme_data_release(self.wrapped)
if self._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(self)
+ pygpgme.pyme_raise_callback_exception(self)
self.wrapped = None
self._free_datacbs()
@@ -918,7 +918,7 @@ class Data(GpgmeWrapper):
else:
hookdata = (weakref.ref(self),
read_cb, write_cb, seek_cb, release_cb)
- pygpgme.pygpgme_data_new_from_cbs(self, hookdata, tmp)
+ pygpgme.pyme_data_new_from_cbs(self, hookdata, tmp)
self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
pygpgme.delete_gpgme_data_t_p(tmp)
@@ -972,7 +972,7 @@ class Data(GpgmeWrapper):
written = pygpgme.gpgme_data_write(self.wrapped, buffer)
if written < 0:
if self._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(self)
+ pygpgme.pyme_raise_callback_exception(self)
else:
raise GPGMEError.fromSyserror()
return written
@@ -993,7 +993,7 @@ class Data(GpgmeWrapper):
result = pygpgme.gpgme_data_read(self.wrapped, size)
except:
if self._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(self)
+ pygpgme.pyme_raise_callback_exception(self)
else:
raise
return result
@@ -1004,7 +1004,7 @@ class Data(GpgmeWrapper):
result = pygpgme.gpgme_data_read(self.wrapped, 4096)
except:
if self._callback_excinfo:
- pygpgme.pygpgme_raise_callback_exception(self)
+ pygpgme.pyme_raise_callback_exception(self)
else:
raise
if len(result) == 0:
commit 1d2f22aae668ce136cacd254875e118dc1faa6a2
Author: Justus Winter <justus at g10code.com>
Date: Thu Jul 28 14:51:20 2016 +0200
python: Rename private functions.
Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.
This commit renames all functions that are not exported to the Python
world.
* lang/python/gpgme.i: Rename all private functions.
* lang/python/helpers.c: Likewise.
* lang/python/helpers.h: Likewise.
* lang/python/private.h: Likewise. Also move the SWIG runtime helper
prototypes here.
Signed-off-by: Justus Winter <justus at g10code.com>
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index 24adf74..11af994 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -135,7 +135,7 @@
$1 = NULL;
else {
PyObject *pypointer;
- pypointer = object_to_gpgme_data_t($input, $argnum, &wrapper,
+ pypointer = _pyme_obj2gpgme_data_t($input, $argnum, &wrapper,
&bytesio, &view);
if (pypointer == NULL)
return NULL;
@@ -349,7 +349,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "EncryptResult");
+ $result = _pyme_wrap_result(fragile, "EncryptResult");
Py_DECREF(fragile);
}
@@ -357,7 +357,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "DecryptResult");
+ $result = _pyme_wrap_result(fragile, "DecryptResult");
Py_DECREF(fragile);
}
@@ -365,7 +365,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "SignResult");
+ $result = _pyme_wrap_result(fragile, "SignResult");
Py_DECREF(fragile);
}
@@ -373,7 +373,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "VerifyResult");
+ $result = _pyme_wrap_result(fragile, "VerifyResult");
Py_DECREF(fragile);
}
@@ -381,7 +381,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "ImportResult");
+ $result = _pyme_wrap_result(fragile, "ImportResult");
Py_DECREF(fragile);
}
@@ -389,7 +389,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "GenkeyResult");
+ $result = _pyme_wrap_result(fragile, "GenkeyResult");
Py_DECREF(fragile);
}
@@ -397,7 +397,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "KeylistResult");
+ $result = _pyme_wrap_result(fragile, "KeylistResult");
Py_DECREF(fragile);
}
@@ -405,7 +405,7 @@
PyObject *fragile;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
%newpointer_flags);
- $result = pygpgme_wrap_fragile_result(fragile, "VFSMountResult");
+ $result = _pyme_wrap_result(fragile, "VFSMountResult");
Py_DECREF(fragile);
}
@@ -421,7 +421,7 @@
PyObject *fragile, *o;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor,
%newpointer_flags);
- o = pygpgme_wrap_fragile_result(fragile, "EngineInfo");
+ o = _pyme_wrap_result(fragile, "EngineInfo");
if (o == NULL)
return NULL; /* raise */
Py_DECREF(fragile);
@@ -439,7 +439,7 @@
return PyErr_Format(PyExc_TypeError,
"edit callback must be a tuple of size 2 or 3");
- $1 = (gpgme_edit_cb_t) pyEditCb;
+ $1 = (gpgme_edit_cb_t) _pyme_edit_cb;
$2 = $input;
}
@@ -555,15 +555,15 @@ FILE *fdopen(int fildes, const char *mode);
#include "helpers.h"
#include "private.h"
-/* SWIG support for helpers.c */
+/* SWIG runtime support for helpers.c */
PyObject *
-pygpgme_wrap_gpgme_data_t(gpgme_data_t data)
+_pyme_wrap_gpgme_data_t(gpgme_data_t data)
{
return SWIG_Python_NewPointerObj(NULL, data, SWIGTYPE_p_gpgme_data, 0);
}
gpgme_ctx_t
-pygpgme_unwrap_gpgme_ctx_t(PyObject *wrapped)
+_pyme_unwrap_gpgme_ctx_t(PyObject *wrapped)
{
gpgme_ctx_t result;
if (SWIG_ConvertPtr(wrapped,
diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index 90173e4..27e7274 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -30,7 +30,7 @@
static PyObject *GPGMEError = NULL;
-void pygpgme_exception_init(void) {
+void _pyme_exception_init(void) {
if (GPGMEError == NULL) {
PyObject *errors;
PyObject *from_list = PyList_New(0);
@@ -45,11 +45,11 @@ void pygpgme_exception_init(void) {
}
static PyObject *
-pygpgme_raise_exception(gpgme_error_t err)
+_pyme_raise_exception(gpgme_error_t err)
{
PyObject *e;
- pygpgme_exception_init();
+ _pyme_exception_init();
if (GPGMEError == NULL)
return PyErr_Format(PyExc_RuntimeError, "Got gpgme_error_t %d", err);
@@ -63,7 +63,7 @@ pygpgme_raise_exception(gpgme_error_t err)
return NULL; /* raise */
}
-gpgme_error_t pygpgme_exception2code(void) {
+gpgme_error_t _pyme_exception2code(void) {
gpgme_error_t err_status = gpg_error(GPG_ERR_GENERAL);
if (GPGMEError && PyErr_ExceptionMatches(GPGMEError)) {
PyObject *type = 0, *value = 0, *traceback = 0;
@@ -81,7 +81,7 @@ gpgme_error_t pygpgme_exception2code(void) {
/* Exception support for callbacks. */
#define EXCINFO "_callback_excinfo"
-static void pygpgme_stash_callback_exception(PyObject *weak_self)
+static void _pyme_stash_callback_exception(PyObject *weak_self)
{
PyObject *self, *ptype, *pvalue, *ptraceback, *excinfo;
@@ -176,7 +176,7 @@ PyObject *pygpgme_raise_callback_exception(PyObject *self)
/* Convert object to a pointer to gpgme type, generic version. */
PyObject *
-object_to_gpgme_t(PyObject *input, const char *objtype, int argnum)
+_pyme_obj2gpgme_t(PyObject *input, const char *objtype, int argnum)
{
PyObject *pyname = NULL, *pypointer = NULL;
pyname = PyObject_GetAttrString(input, "_ctype");
@@ -210,7 +210,7 @@ object_to_gpgme_t(PyObject *input, const char *objtype, int argnum)
objects with a fileno method, returning it in WRAPPER. This object
must be de-referenced when no longer needed. */
PyObject *
-object_to_gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
+_pyme_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
PyObject **bytesio, Py_buffer *view)
{
gpgme_error_t err;
@@ -223,9 +223,9 @@ object_to_gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
err = gpgme_data_new_from_fd(wrapper, (int) PyLong_AsLong(fd));
Py_DECREF(fd);
if (err)
- return pygpgme_raise_exception (err);
+ return _pyme_raise_exception (err);
- return pygpgme_wrap_gpgme_data_t(*wrapper);
+ return _pyme_wrap_gpgme_data_t(*wrapper);
}
else
PyErr_Clear();
@@ -264,14 +264,14 @@ object_to_gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
err = gpgme_data_new_from_mem(wrapper, view->buf, (size_t) view->len, 0);
if (err)
- return pygpgme_raise_exception (err);
+ return _pyme_raise_exception (err);
- return pygpgme_wrap_gpgme_data_t(*wrapper);
+ return _pyme_wrap_gpgme_data_t(*wrapper);
}
/* As last resort we assume it is a wrapped data object. */
if (PyObject_HasAttrString(data, "_ctype"))
- return object_to_gpgme_t(data, "gpgme_data_t", argnum);
+ return _pyme_obj2gpgme_t(data, "gpgme_data_t", argnum);
return PyErr_Format(PyExc_TypeError,
"arg %d: expected pyme.Data, file, or an object "
@@ -282,7 +282,7 @@ object_to_gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
PyObject *
-pygpgme_wrap_fragile_result(PyObject *fragile, const char *classname)
+_pyme_wrap_result(PyObject *fragile, const char *classname)
{
static PyObject *results;
PyObject *class;
@@ -327,7 +327,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
PyObject *dataarg = NULL;
gpgme_error_t err_status = 0;
- pygpgme_exception_init();
+ _pyme_exception_init();
assert (PyTuple_Check(pyhook));
assert (PyTuple_Size(pyhook) == 2 || PyTuple_Size(pyhook) == 3);
@@ -364,12 +364,12 @@ static gpgme_error_t pyPassphraseCb(void *hook,
retval = PyObject_CallObject(func, args);
Py_DECREF(args);
if (PyErr_Occurred()) {
- err_status = pygpgme_exception2code();
+ err_status = _pyme_exception2code();
} else {
if (!retval) {
if (write(fd, "\n", 1) < 0) {
err_status = gpgme_error_from_syserror ();
- pygpgme_raise_exception (err_status);
+ _pyme_raise_exception (err_status);
}
} else {
char *buf;
@@ -394,11 +394,11 @@ static gpgme_error_t pyPassphraseCb(void *hook,
if (write(fd, buf, len) < 0) {
err_status = gpgme_error_from_syserror ();
- pygpgme_raise_exception (err_status);
+ _pyme_raise_exception (err_status);
}
if (! err_status && write(fd, "\n", 1) < 0) {
err_status = gpgme_error_from_syserror ();
- pygpgme_raise_exception (err_status);
+ _pyme_raise_exception (err_status);
}
Py_DECREF(retval);
@@ -407,7 +407,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
leave:
if (err_status)
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
return err_status;
}
@@ -424,7 +424,7 @@ pygpgme_set_passphrase_cb(PyObject *self, PyObject *cb) {
return NULL;
}
- ctx = pygpgme_unwrap_gpgme_ctx_t(wrapped);
+ ctx = _pyme_unwrap_gpgme_ctx_t(wrapped);
Py_DECREF(wrapped);
if (ctx == NULL)
{
@@ -475,7 +475,7 @@ static void pyProgressCb(void *hook, const char *what, int type, int current,
PyTuple_SetItem(args, 0, PyUnicode_DecodeUTF8(what, strlen (what),
"strict"));
if (PyErr_Occurred()) {
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
Py_DECREF(args);
return;
}
@@ -489,7 +489,7 @@ static void pyProgressCb(void *hook, const char *what, int type, int current,
retval = PyObject_CallObject(func, args);
if (PyErr_Occurred())
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
Py_DECREF(args);
Py_XDECREF(retval);
}
@@ -506,7 +506,7 @@ pygpgme_set_progress_cb(PyObject *self, PyObject *cb) {
return NULL;
}
- ctx = pygpgme_unwrap_gpgme_ctx_t(wrapped);
+ ctx = _pyme_unwrap_gpgme_ctx_t(wrapped);
Py_DECREF(wrapped);
if (ctx == NULL)
{
@@ -581,13 +581,13 @@ static gpgme_error_t pyStatusCb(void *hook, const char *keyword,
retval = PyObject_CallObject(func, pyargs);
if (PyErr_Occurred())
- err = pygpgme_exception2code();
+ err = _pyme_exception2code();
Py_DECREF(pyargs);
Py_XDECREF(retval);
leave:
if (err)
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
return err;
}
@@ -603,7 +603,7 @@ pygpgme_set_status_cb(PyObject *self, PyObject *cb) {
return NULL;
}
- ctx = pygpgme_unwrap_gpgme_ctx_t(wrapped);
+ ctx = _pyme_unwrap_gpgme_ctx_t(wrapped);
Py_DECREF(wrapped);
if (ctx == NULL)
{
@@ -634,14 +634,14 @@ pygpgme_set_status_cb(PyObject *self, PyObject *cb) {
}
/* Edit callbacks. */
-gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status,
+gpgme_error_t _pyme_edit_cb(void *opaque, gpgme_status_code_t status,
const char *args, int fd) {
PyObject *func = NULL, *dataarg = NULL, *pyargs = NULL, *retval = NULL;
PyObject *pyopaque = (PyObject *) opaque;
gpgme_error_t err_status = 0;
PyObject *self = NULL;
- pygpgme_exception_init();
+ _pyme_exception_init();
assert (PyTuple_Check(pyopaque));
assert (PyTuple_Size(pyopaque) == 2 || PyTuple_Size(pyopaque) == 3);
@@ -664,7 +664,7 @@ gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status,
retval = PyObject_CallObject(func, pyargs);
Py_DECREF(pyargs);
if (PyErr_Occurred()) {
- err_status = pygpgme_exception2code();
+ err_status = _pyme_exception2code();
} else {
if (fd>=0 && retval && PyUnicode_Check(retval)) {
const char *buffer;
@@ -673,16 +673,16 @@ gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status,
buffer = PyUnicode_AsUTF8AndSize(retval, &size);
if (write(fd, buffer, size) < 0) {
err_status = gpgme_error_from_syserror ();
- pygpgme_raise_exception (err_status);
+ _pyme_raise_exception (err_status);
}
if (! err_status && write(fd, "\n", 1) < 0) {
err_status = gpgme_error_from_syserror ();
- pygpgme_raise_exception (err_status);
+ _pyme_raise_exception (err_status);
}
}
}
if (err_status)
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
Py_XDECREF(retval);
return err_status;
@@ -724,7 +724,7 @@ static ssize_t pyDataReadCb(void *hook, void *buffer, size_t size)
retval = PyObject_CallObject(func, pyargs);
Py_DECREF(pyargs);
if (PyErr_Occurred()) {
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
result = -1;
goto leave;
}
@@ -733,7 +733,7 @@ static ssize_t pyDataReadCb(void *hook, void *buffer, size_t size)
PyErr_Format(PyExc_TypeError,
"expected bytes from read callback, got %s",
retval->ob_type->tp_name);
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
result = -1;
goto leave;
}
@@ -742,7 +742,7 @@ static ssize_t pyDataReadCb(void *hook, void *buffer, size_t size)
PyErr_Format(PyExc_TypeError,
"expected %zu bytes from read callback, got %zu",
size, PyBytes_Size(retval));
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
result = -1;
goto leave;
}
@@ -789,7 +789,7 @@ static ssize_t pyDataWriteCb(void *hook, const void *buffer, size_t size)
retval = PyObject_CallObject(func, pyargs);
Py_DECREF(pyargs);
if (PyErr_Occurred()) {
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
result = -1;
goto leave;
}
@@ -798,7 +798,7 @@ static ssize_t pyDataWriteCb(void *hook, const void *buffer, size_t size)
PyErr_Format(PyExc_TypeError,
"expected int from read callback, got %s",
retval->ob_type->tp_name);
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
result = -1;
goto leave;
}
@@ -850,7 +850,7 @@ static off_t pyDataSeekCb(void *hook, off_t offset, int whence)
retval = PyObject_CallObject(func, pyargs);
Py_DECREF(pyargs);
if (PyErr_Occurred()) {
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
result = -1;
goto leave;
}
@@ -859,7 +859,7 @@ static off_t pyDataSeekCb(void *hook, off_t offset, int whence)
PyErr_Format(PyExc_TypeError,
"expected int from read callback, got %s",
retval->ob_type->tp_name);
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
result = -1;
goto leave;
}
@@ -906,7 +906,7 @@ static void pyDataReleaseCb(void *hook)
Py_XDECREF(retval);
Py_DECREF(pyargs);
if (PyErr_Occurred())
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
}
PyObject *
@@ -930,7 +930,7 @@ pygpgme_data_new_from_cbs(PyObject *self,
err = gpgme_data_new_from_cbs(r_data, &cbs, (void *) pycbs);
if (err)
- return pygpgme_raise_exception(err);
+ return _pyme_raise_exception(err);
PyObject_SetAttrString(self, "_data_cbs", pycbs);
@@ -964,13 +964,13 @@ _pyme_assuan_data_cb (void *hook, const void *data, size_t datalen)
retval = PyObject_CallFunctionObjArgs(func, py_data, NULL);
if (PyErr_Occurred())
- err = pygpgme_exception2code();
+ err = _pyme_exception2code();
Py_DECREF(py_data);
Py_XDECREF(retval);
leave:
if (err)
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
return err;
}
@@ -1002,7 +1002,7 @@ _pyme_assuan_inquire_cb (void *hook, const char *name, const char *args,
retval = PyObject_CallFunctionObjArgs(func, py_name, py_args, NULL);
if (PyErr_Occurred())
- err = pygpgme_exception2code();
+ err = _pyme_exception2code();
Py_DECREF(py_name);
Py_DECREF(py_args);
Py_XDECREF(retval);
@@ -1012,7 +1012,7 @@ _pyme_assuan_inquire_cb (void *hook, const char *name, const char *args,
leave:
if (err)
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
return err;
}
@@ -1043,13 +1043,13 @@ _pyme_assuan_status_cb (void *hook, const char *status, const char *args)
retval = PyObject_CallFunctionObjArgs(func, py_status, py_args, NULL);
if (PyErr_Occurred())
- err = pygpgme_exception2code();
+ err = _pyme_exception2code();
Py_DECREF(py_status);
Py_DECREF(py_args);
Py_XDECREF(retval);
leave:
if (err)
- pygpgme_stash_callback_exception(self);
+ _pyme_stash_callback_exception(self);
return err;
}
diff --git a/lang/python/helpers.h b/lang/python/helpers.h
index 4bfb664..f41d327 100644
--- a/lang/python/helpers.h
+++ b/lang/python/helpers.h
@@ -34,7 +34,3 @@ PyObject *pygpgme_set_status_cb(PyObject *self, PyObject *cb);
PyObject *pygpgme_data_new_from_cbs(PyObject *self, PyObject *pycbs,
gpgme_data_t *r_data);
-
-/* SWIG support for helpers.c */
-PyObject *pygpgme_wrap_gpgme_data_t(gpgme_data_t data);
-gpgme_ctx_t pygpgme_unwrap_gpgme_ctx_t(PyObject *wrapped);
diff --git a/lang/python/private.h b/lang/python/private.h
index 88b9653..cb4d2f8 100644
--- a/lang/python/private.h
+++ b/lang/python/private.h
@@ -22,18 +22,20 @@
#ifndef _PYME_PRIVATE_H_
#define _PYME_PRIVATE_H_
-void pygpgme_exception_init(void);
-gpgme_error_t pygpgme_exception2code(void);
+/* GPGME glue. Implemented in helpers.c. */
-PyObject *object_to_gpgme_t(PyObject *input, const char *objtype, int argnum);
-PyObject *object_to_gpgme_data_t(PyObject *input, int argnum,
+void _pyme_exception_init(void);
+gpgme_error_t _pyme_exception2code(void);
+
+PyObject *_pyme_obj2gpgme_t(PyObject *input, const char *objtype, int argnum);
+PyObject *_pyme_obj2gpgme_data_t(PyObject *input, int argnum,
gpgme_data_t *wrapper,
PyObject **bytesio, Py_buffer *view);
-PyObject *pygpgme_wrap_fragile_result(PyObject *fragile, const char *classname);
+PyObject *_pyme_wrap_result(PyObject *fragile, const char *classname);
-gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status,
- const char *args, int fd);
+gpgme_error_t _pyme_edit_cb(void *opaque, gpgme_status_code_t status,
+ const char *args, int fd);
gpgme_error_t _pyme_assuan_data_cb (void *hook,
const void *data, size_t datalen);
@@ -43,4 +45,11 @@ gpgme_error_t _pyme_assuan_inquire_cb (void *hook,
gpgme_error_t _pyme_assuan_status_cb (void *hook,
const char *status, const char *args);
+
+
+/* SWIG runtime support. Implemented in gpgme.i. */
+
+PyObject *_pyme_wrap_gpgme_data_t(gpgme_data_t data);
+gpgme_ctx_t _pyme_unwrap_gpgme_ctx_t(PyObject *wrapped);
+
#endif /* _PYME_PRIVATE_H_ */
-----------------------------------------------------------------------
Summary of changes:
lang/python/Makefile.am | 2 +-
lang/python/gpgme.i | 30 +++---
lang/python/helpers.c | 108 ++++++++++----------
lang/python/helpers.h | 16 ++-
lang/python/private.h | 23 +++--
lang/python/pyme/__init__.py | 21 +++-
lang/python/pyme/core.py | 196 ++++++++++++++++++------------------
lang/python/pyme/errors.py | 21 ++--
lang/python/pyme/util.py | 7 +-
lang/python/pyme/version.py.in | 7 +-
lang/python/setup.py.in | 2 +-
lang/python/tests/t-keylist.py | 2 -
lang/python/tests/t-sig-notation.py | 2 +-
lang/python/tests/t-sign.py | 1 -
lang/python/tests/t-signers.py | 1 -
15 files changed, 231 insertions(+), 208 deletions(-)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list