summaryrefslogtreecommitdiff
path: root/jq.pyx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-03-27 13:57:53 +0000
committerMichael Williamson <mike@zwobble.org>2014-03-27 13:57:53 +0000
commitd9cae8c701c21d401551ed1d551ced7324fd7114 (patch)
tree796d0a2a64c3238bdc0e64c713283f772ec671e5 /jq.pyx
parent74ae5d3c23732ec50e15cbf3a93cf7295604301d (diff)
Clear errors before each transformation
Diffstat (limited to 'jq.pyx')
-rw-r--r--jq.pyx8
1 files changed, 7 insertions, 1 deletions
diff --git a/jq.pyx b/jq.pyx
index 085a345..5e49c34 100644
--- a/jq.pyx
+++ b/jq.pyx
@@ -55,7 +55,7 @@ def jq(object program):
raise Exception("jq_init failed")
cdef _ErrorStore error_store = _ErrorStore.__new__(_ErrorStore)
- error_store._errors = []
+ error_store.clear()
jq_set_error_cb(jq, store_error, <void*>error_store)
@@ -91,6 +91,9 @@ cdef class _ErrorStore(object):
cdef void store_error(self, char* error):
self._errors.append(error)
+
+ cdef void clear(self):
+ self._errors = []
cdef class _Program(object):
@@ -103,6 +106,9 @@ cdef class _Program(object):
def transform(self, input, raw_input=False, raw_output=False, multiple_output=False):
string_input = input if raw_input else json.dumps(input)
bytes_input = string_input.encode("utf8")
+
+ self._error_store.clear()
+
result_bytes = self._string_to_strings(bytes_input)
if self._error_store.has_errors():