From f8f7019ffdf9b4e05faf95e1f04e204aa4c91f98 Mon Sep 17 00:00:00 2001 From: Nicola Iarocci Date: Sun, 14 Jan 2018 17:51:26 +0100 Subject: [PATCH] fix mongo visitor parser --- eve/io/mongo/parser.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/eve/io/mongo/parser.py b/eve/io/mongo/parser.py index 6b751203b..ac633c098 100644 --- a/eve/io/mongo/parser.py +++ b/eve/io/mongo/parser.py @@ -122,16 +122,19 @@ def visit_Call(self, node): datetime(). """ if isinstance(node.func, ast.Name): - expr = None if node.func.id == 'ObjectId': - expr = "('" + node.args[0].s + "')" + try: + self.current_value = ObjectId(node.args[0].s) + except: + pass elif node.func.id == 'datetime': values = [] for arg in node.args: - values.append(str(arg.n)) - expr = "(" + ", ".join(values) + ")" - if expr: - self.current_value = eval(node.func.id + expr) + values.append(arg.n) + try: + self.current_value = datetime(*values) + except: + pass def visit_Attribute(self, node): """ Attribute handler ('Contact.Id').