From 1ed2d45ac44912073a7d9adc957d791bea4d9282 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Thu, 29 Aug 2019 17:17:52 +0200 Subject: [PATCH] obi grep: made an error message clearer (error could be eventually be handled by program, looking for str in bytes returned by a column) --- python/obitools3/commands/grep.pyx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/obitools3/commands/grep.pyx b/python/obitools3/commands/grep.pyx index a32995d..78bb516 100644 --- a/python/obitools3/commands/grep.pyx +++ b/python/obitools3/commands/grep.pyx @@ -207,9 +207,12 @@ def Filter_generator(options, tax_filter): ) if good and predicates: - good = (reduce(lambda bint x, bint y: x and y, - (bool(eval(p, loc_env, line)) - for p in predicates), True)) + try: + good = (reduce(lambda bint x, bint y: x and y, + (bool(eval(p, loc_env, line)) + for p in predicates), True)) + except TypeError: + raise Exception("Try replacing strings in python expression with bytes (by putting 'b' in front of strings, e.g. b'example')") if good and lmin: good = len(line) >= lmin