Commit aa8af02d authored by Jérome Perrin's avatar Jérome Perrin

fixup! fixup! fixup! fixup! fixup! fixup! ERP5 py3: WIP ( all changes squashed )

parent 778074eb
Pipeline #33331 failed with stage
in 0 seconds
From cd7e5680a120b3191966657723feae7d5c6bf348 Mon Sep 17 00:00:00 2001
From 3666a7afd46ea6d069606450c520b8b7e2b5fddf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 22 Feb 2024 23:33:41 +0900
Subject: [PATCH] Make dict views behave like their unrestricted versions
......@@ -13,10 +13,10 @@ During this refactoring, also change `.items()` to validate
ach keys and values, like `.keys()` and `.values()` do.
---
CHANGES.rst | 7 ++++
src/AccessControl/ZopeGuards.py | 48 +++++++++++++++++------
src/AccessControl/tests/actual_python.py | 29 ++++++++++++++
src/AccessControl/tests/testZopeGuards.py | 34 +++++++++++-----
4 files changed, 98 insertions(+), 20 deletions(-)
src/AccessControl/ZopeGuards.py | 50 ++++++++++++++++++-----
src/AccessControl/tests/actual_python.py | 33 +++++++++++++++
src/AccessControl/tests/testZopeGuards.py | 34 +++++++++++----
4 files changed, 104 insertions(+), 20 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index f35a8d2..073b791 100644
......@@ -37,7 +37,7 @@ index f35a8d2..073b791 100644
6.3 (2023-11-20)
----------------
diff --git a/src/AccessControl/ZopeGuards.py b/src/AccessControl/ZopeGuards.py
index 84c2e9e..c89068a 100644
index 84c2e9e..bc24941 100644
--- a/src/AccessControl/ZopeGuards.py
+++ b/src/AccessControl/ZopeGuards.py
@@ -12,6 +12,7 @@
......@@ -94,11 +94,13 @@ index 84c2e9e..c89068a 100644
def _check_dict_access(name, value):
# Check whether value is a dict method
@@ -262,6 +265,29 @@ def __next__(self):
@@ -262,6 +265,31 @@ def __next__(self):
next = __next__
+class _SafeMappingView:
+ __allow_access_to_unprotected_subobjects__ = 1
+
+ def __iter__(self):
+ for e in super().__iter__():
+ guard(self._mapping, e)
......@@ -125,10 +127,10 @@ index 84c2e9e..c89068a 100644
def __init__(self, ob):
self._iter = ob
diff --git a/src/AccessControl/tests/actual_python.py b/src/AccessControl/tests/actual_python.py
index 3405b8e..337275d 100644
index 3405b8e..866a480 100644
--- a/src/AccessControl/tests/actual_python.py
+++ b/src/AccessControl/tests/actual_python.py
@@ -123,6 +123,35 @@ def f7():
@@ -123,6 +123,39 @@ def f7():
access = getattr(d, meth)
result = sorted(access())
assert result == expected[kind], (meth, kind, result, expected[kind])
......@@ -136,6 +138,10 @@ index 3405b8e..337275d 100644
+ iter_ = access() # iterate twice on the same view
+ assert list(iter_) == list(iter_)
+
+ assert sorted([k for k in getattr(d, meth)()]) == expected[kind]
+ assert sorted(k for k in getattr(d, meth)()) == expected[kind]
+ assert {k: v for k, v in d.items()} == d
+
+ assert 1 in d
+ assert 1 in d.keys()
+ assert 2 in d.values()
......
......@@ -716,7 +716,7 @@ Zope-patches =
Zope-patch-options = -p1
[eggs:python3]
AccessControl-patches = ${:_profile_base_location_}/../../component/egg-patch/AccessControl/147.patch#54f19d3b58850f7dc58b16884425d8bb
AccessControl-patches = ${:_profile_base_location_}/../../component/egg-patch/AccessControl/147.patch#5eb2b07dc79bef05dbc0c60d046d2847
AccessControl-patch-options = -p1
interval-patches = ${:_profile_base_location_}/../../component/egg-patch/interval/0001-python3-support.patch#66ac345f0a6d73e0bd29e394b7646311
interval-patch-options = -p1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment