Skip to content

Commit 932064f

Browse files
etienne-lebrunChimou0
authored andcommitted
fix: apache#238, avoid calling has_eval in enforcing loop (apache#240)
1 parent f2c9186 commit 932064f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

casbin/core_enforcer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ def enforce_ex(self, *rvals):
366366
raise RuntimeError("invalid request size")
367367

368368
exp_string = self.model["m"][mtype].value
369-
has_eval = util.has_eval(exp_string)
370-
if not has_eval:
369+
exp_has_eval = util.has_eval(exp_string)
370+
if not exp_has_eval:
371371
expression = self._get_expression(exp_string, functions)
372372

373373
policy_effects = set()
@@ -385,7 +385,7 @@ def enforce_ex(self, *rvals):
385385
p_parameters = dict(zip(p_tokens, pvals))
386386
parameters = dict(r_parameters, **p_parameters)
387387

388-
if util.has_eval(exp_string):
388+
if exp_has_eval:
389389
rule_names = util.get_eval_value(exp_string)
390390
rules = [
391391
util.escape_assertion(p_parameters[rule_name])
@@ -427,7 +427,7 @@ def enforce_ex(self, *rvals):
427427
break
428428

429429
else:
430-
if has_eval:
430+
if exp_has_eval:
431431
raise RuntimeError(
432432
"please make sure rule exists in policy when using eval() in matcher"
433433
)

0 commit comments

Comments
 (0)