From 32451fc063568b147ebf773a3f122fb1f5bfe097 Mon Sep 17 00:00:00 2001 From: Juan-Pablo Scaletti Date: Tue, 3 Oct 2023 13:26:50 -0500 Subject: [PATCH] Fix tests for py39 and add py312 --- pyproject.toml | 2 +- src/jinjax/component.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 03ab192..3b4aafc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,7 +119,7 @@ addopts = "--doctest-modules" legacy_tox_ini = """ [tox] skipsdist = True -envlist = py39,py310,py311 +envlist = py39,py310,py311,py312 [testenv] skip_install = true diff --git a/src/jinjax/component.py b/src/jinjax/component.py index 51c26ef..ad3eb78 100644 --- a/src/jinjax/component.py +++ b/src/jinjax/component.py @@ -29,7 +29,10 @@ def eval_expression(input_string): for name in code.co_names: if name not in ALLOWED_NAMES_IN_EXPRESSION_VALUES: raise InvalidArgument(f"Use of {name} not allowed") - return eval(code, {"__builtins__": {}}, ALLOWED_NAMES_IN_EXPRESSION_VALUES) + try: + return eval(code, {"__builtins__": {}}, ALLOWED_NAMES_IN_EXPRESSION_VALUES) + except NameError as err: + raise InvalidArgument(err) def is_valid_variable_name(name):