This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-pycasbin.git
The following commit(s) were added to refs/heads/master by this push:
new 17b2e8c fix: add deepcopy to not clone rm and cond_rm (#423)
17b2e8c is described below
commit 17b2e8c244a1e52704819906216debb0950bca71
Author: Kenneth Goh <[email protected]>
AuthorDate: Tue Aug 4 14:23:57 2026 +0800
fix: add deepcopy to not clone rm and cond_rm (#423)
---
casbin/model/assertion.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/casbin/model/assertion.py b/casbin/model/assertion.py
index 120ce34..88096a0 100644
--- a/casbin/model/assertion.py
+++ b/casbin/model/assertion.py
@@ -13,7 +13,7 @@
# limitations under the License.
import logging
-
+import copy
from casbin.model.policy_op import PolicyOp
@@ -109,3 +109,17 @@ class Assertion:
domain = domain_rule[0]
self.cond_rm.add_link(rule[0], rule[1], domain)
self.cond_rm.set_domain_link_condition_func_params(rule[0],
rule[1], domain, *rule[len(self.tokens) :])
+
+ def __deepcopy__(self, memo):
+ """Custom deepcopy implementation that excludes rm and cond_rm
attributes.
+ This stems from an issue with the watcher concurrent reloading causing
an edge case of deepcopy error.
+ """
+ cls = self.__class__
+ result = cls.__new__(cls)
+ memo[id(self)] = result
+ for k, v in self.__dict__.items():
+ if k in ("rm", "cond_rm"):
+ setattr(result, k, None)
+ else:
+ setattr(result, k, copy.deepcopy(v, memo))
+ return result
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]