Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cel_expr_python/cel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,22 @@ def testProtoMessageToCelValueError(self):
self.assertEqual(res.type(), cel.Type.ERROR)
self.assertIn("Custom pool error", str(res.value()))

def testValueOutlivesExpression(self):
expr: cel.Expression = self.env.compile("'hello ' + 'world'")
val: cel.Value = expr.eval()
del expr
self.assertEqual(val.value(), "hello world")

expr = self.env.compile("b'hello'")
val = expr.eval()
del expr
self.assertEqual(val.value(), b"hello")

expr = self.env.compile("['a', 'b', 'c']")
val = expr.eval()
del expr
self.assertEqual(val.plain_value(), ["a", "b", "c"])


class CompatibleNumber:

Expand Down
1 change: 1 addition & 0 deletions cel_expr_python/py_cel_expression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ absl::StatusOr<PyCelValue> PyCelExpression::Eval(
result,
program->Evaluate(arena->GetArena(), *activation.GetActivation(),
std::move(options)));
result = result.Clone(arena->GetArena());
}
return PyCelValue(result, arena, std::move(env));
}
Expand Down
Loading