Skip to content

Commit 1a643ed

Browse files
shivanand-adkyclaude
authored andcommitted
Fix: wrap fail.items() in list() to prevent Py2->Py3 dict mutation error
In Python 2, dict.items() returned a list copy; in Python 3 it returns a view, so calling fail.pop(key) inside the loop raises RuntimeError. Fixed in batch_create, batch_update, and batch_replace. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Change-Id: I38627dfab8cec6e3243fa0960f2b309e89759fce Reviewed-on: https://review.couchbase.org/c/TAF/+/245679 Tested-by: Ashwin <ashwin.govindarajulu@couchbase.com> Reviewed-by: Ashwin <ashwin.govindarajulu@couchbase.com>
1 parent 5eab5f1 commit 1a643ed

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/Jython_tasks/task.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ def batch_create(self, key_val, client=None, persist_to=0,
10991099
# self.test_log.debug("Reading values {0} after failure"
11001100
# .format(fail.keys()))
11011101
read_map, read_fail = self.batch_read(list(fail.keys()))
1102-
for key, value in fail.items():
1102+
for key, value in list(fail.items()):
11031103
if key in read_map and read_map[key]["cas"] != 0:
11041104
success[key] = value
11051105
success[key].pop("error", None)
@@ -1147,7 +1147,7 @@ def batch_update(self, key_val, client=None, persist_to=0,
11471147
self.test_log.debug("Reading values {0} after failure"
11481148
.format(fail.keys()))
11491149
read_map, _ = self.batch_read(list(fail.keys()))
1150-
for key, value in fail.items():
1150+
for key, value in list(fail.items()):
11511151
if key in read_map and read_map[key]["cas"] != 0 \
11521152
and value == read_map[key]["value"]:
11531153
success[key] = value
@@ -1197,7 +1197,7 @@ def batch_replace(self, key_val, client=None, persist_to=0,
11971197
self.test_log.debug("Reading values {0} after failure"
11981198
.format(fail.keys()))
11991199
read_map, _ = self.batch_read(list(fail.keys()))
1200-
for key, value in fail.items():
1200+
for key, value in list(fail.items()):
12011201
if key in read_map and read_map[key]["cas"] != 0:
12021202
success[key] = value
12031203
success[key].pop("error")

0 commit comments

Comments
 (0)