aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/helpers.c
diff options
context:
space:
mode:
authorTobias Mueller <[email protected]>2016-12-02 22:37:27 +0000
committerJustus Winter <[email protected]>2016-12-05 11:44:20 +0000
commit05896c210f7fa9ce7b97784a75e49dc4489e9252 (patch)
tree10e20776c4e885ab14ae115181ff88a5ff997321 /lang/python/helpers.c
parentpython: Define a macro for wrapping fragile result objects. (diff)
downloadgpgme-05896c210f7fa9ce7b97784a75e49dc4489e9252.tar.gz
gpgme-05896c210f7fa9ce7b97784a75e49dc4489e9252.zip
python: Try to be more helpful when given a string to encrypt().
* lang/python/helpers.c (_gpg_obj2gpgme_data_t): Extended error message. * lang/python/tests/t-encrypt.py: Test for "encode" in error message. -- The motivation is to help the user when encrypting fails. I claim that it is not obvious to not being able to encrypt a string directly. To nudge the user into encoding it to bytes, the error message is a bit extended. Signed-off-by: Tobias Mueller <[email protected]>
Diffstat (limited to 'lang/python/helpers.c')
-rw-r--r--lang/python/helpers.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index 8f71a305..576767ca 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -293,8 +293,10 @@ _gpg_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
return _gpg_obj2gpgme_t(data, "gpgme_data_t", argnum);
return PyErr_Format(PyExc_TypeError,
- "arg %d: expected gpg.Data, file, or an object "
- "implementing the buffer protocol, got %s",
+ "arg %d: expected gpg.Data, file, "
+ "bytes (not string!), or an object "
+ "implementing the buffer protocol. Got: %s. "
+ "If you provided a string, try to encode() it.",
argnum, data->ob_type->tp_name);
}