From a868498469985d721bdc54e6667c9a705a511333 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 26 Mar 2018 13:41:35 +0545 Subject: [PATCH] Replace assertions with fixed checks; closes #157. --- mitogen/core.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mitogen/core.py b/mitogen/core.py index 35972559..09420926 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -108,7 +108,8 @@ class CallError(Error): def _unpickle_call_error(s): - assert type(s) is str and len(s) < 10000 + if not (type(s) is str and len(s) < 10000): + raise TypeError('cannot unpickle CallError: bad input') inst = CallError.__new__(CallError) Exception.__init__(inst, s) return inst @@ -900,9 +901,10 @@ class Context(object): def _unpickle_context(router, context_id, name): - assert isinstance(router, Router) - assert isinstance(context_id, (int, long)) and context_id > 0 - assert isinstance(name, basestring) and len(name) < 100 + if not (isinstance(router, Router) and + isinstance(context_id, (int, long)) and context_id > 0 and + isinstance(name, basestring) and len(name) < 100): + raise TypeError('cannot unpickle Context: bad input') return router.context_class(router, context_id, name)