aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <swo-dev@marcschink.de>2016-11-12 11:55:34 +0100
committerMarc Schink <swo-dev@marcschink.de>2016-11-12 11:55:34 +0100
commit3dfd7e4976fccd1967ea06f82705a3dadf29a68e (patch)
treeda7b506740bc7e3c1f0087a70af9f05014ae21eb
parent85f89c07f34d6d3312a00c23f526db48d97f1e3b (diff)
Python: Allow to disable decoder callback invocation
-rw-r--r--bindings/python/swopy.i6
1 files changed, 6 insertions, 0 deletions
diff --git a/bindings/python/swopy.i b/bindings/python/swopy.i
index 7fbb621..0420571 100644
--- a/bindings/python/swopy.i
+++ b/bindings/python/swopy.i
@@ -264,6 +264,12 @@ static int packet_callback(const libswo::Packet &packet, void *user_data)
void Context::set_callback(PyObject *callback)
{
+ if (callback == Py_None) {
+ Py_XDECREF(_py_callback);
+ libswo::Context::set_callback(NULL, NULL);
+ return;
+ }
+
if (!PyCallable_Check(callback))
throw libswo::Error(LIBSWO_ERR_ARG);