here are two different examples of a failed op_genkey that crashes the python interpreter:
$ python3 -c 'import gpg; c = gpg.Context(); c.op_genkey(None,None,None)' Segmentation fault
$ python3 -c 'import gpg; c = gpg.Context(); parms="<GnupgKeyParms format=\"internal\">\nKey-Type: default\nName-Real: monkeyman\n%commit\n"; c.op_genkey(parms,None,None)' Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python3/dist-packages/gpg/core.py", line 158, in wrapper return _funcwrap(self, *args) File "/usr/lib/python3/dist-packages/gpg/core.py", line 141, in _funcwrap return errorcheck(result, name) File "/usr/lib/python3/dist-packages/gpg/errors.py", line 129, in errorcheck raise GPGMEError(retval, extradata) gpg.errors.GPGMEError: gpgme_op_genkey: GPGME: Cannot allocate memory Segmentation fault
python should never segfault -- errors should raise exceptions.