diff options
author | Jean-Paul Calderone <exarkun@divmod.com> | 2010-08-12 20:03:32 -0400 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@divmod.com> | 2010-08-12 20:03:32 -0400 |
commit | a5a032f46a8254b47ed65459043b4ef8df0c87f5 (patch) | |
tree | 70121893a1111468b29c627161468131e3e168f4 /OpenSSL/util.c | |
parent | c1e89aa7cace980432fd23c651673fb5f2019c31 (diff) | |
download | pyopenssl-a5a032f46a8254b47ed65459043b4ef8df0c87f5.tar.gz |
Stretch compat back to Python 2.4
Diffstat (limited to 'OpenSSL/util.c')
-rw-r--r-- | OpenSSL/util.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/OpenSSL/util.c b/OpenSSL/util.c index ae6ee5e..76a4a25 100644 --- a/OpenSSL/util.c +++ b/OpenSSL/util.c @@ -59,3 +59,35 @@ flush_error_queue(void) { PyObject *list = error_queue_to_list(); Py_DECREF(list); } + +PyObject* PyOpenSSL_LongToHex(PyObject *o) { + PyObject *hex = NULL; + PyObject *format = NULL; + PyObject *format_args = NULL; + + if ((format_args = Py_BuildValue("(O)", o)) == NULL) { + goto err; + } + + if ((format = PyString_FromString("%x")) == NULL) { + goto err; + } + + if ((hex = PyString_Format(format, format_args)) == NULL) { + goto err; + } + + return hex; + + err: + if (format_args) { + Py_DECREF(format_args); + } + if (format) { + Py_DECREF(format); + } + if (hex) { + Py_DECREF(hex); + } + return NULL; +} |