diff options
author | Daniel Elstner <daniel.kitta@gmail.com> | 2015-10-06 22:30:14 +0200 |
---|---|---|
committer | Daniel Elstner <daniel.kitta@gmail.com> | 2015-10-06 23:25:40 +0200 |
commit | e9dd2fea0514df9316a12bae191b810811fc9f01 (patch) | |
tree | d9da0d07b1c8e9076856ae5cbc8500b1502264f2 /exception.c | |
parent | 6d67d057d13318deb0a11de2589b5442df389092 (diff) | |
download | libsigrokdecode-e9dd2fea0514df9316a12bae191b810811fc9f01.tar.gz libsigrokdecode-e9dd2fea0514df9316a12bae191b810811fc9f01.zip |
util: Factor out Python module load
Create a utility function for loading a Python module by its name
in UTF-8.
Diffstat (limited to 'exception.c')
-rw-r--r-- | exception.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/exception.c b/exception.c index a2b2683..7027df5 100644 --- a/exception.c +++ b/exception.c @@ -84,7 +84,7 @@ SRD_PRIV void srd_exception_catch(const char *format, ...) { va_list args; PyObject *py_etype, *py_evalue, *py_etraceback; - PyObject *py_modname, *py_mod, *py_func, *py_tracefmt; + PyObject *py_mod, *py_func, *py_tracefmt; char *msg, *etype_name, *evalue_str, *tracefmt_str; const char *etype_name_fallback; @@ -118,13 +118,7 @@ SRD_PRIV void srd_exception_catch(const char *format, ...) if (!py_etraceback) goto cleanup; - py_modname = PyUnicode_FromString("traceback"); - if (!py_modname) - goto cleanup; - - py_mod = PyImport_Import(py_modname); - Py_DECREF(py_modname); - + py_mod = py_import_by_name("traceback"); if (!py_mod) goto cleanup; |