Commit bd41ba0b authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

py2/py3: explicitly cast dict.items() to list when we delete an item in the loop.

parent 854b9012
......@@ -55,6 +55,7 @@ from zExceptions import Forbidden
from Products.ERP5Type.PsycoWrapper import psyco
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import ensure_list
class FieldValueCacheDict(dict):
_last_sync = -1
......@@ -1039,7 +1040,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
return a==b
def remove_same_value(new_dict, target_dict):
for key, value in new_dict.items():
for key, value in ensure_list(new_dict.items()):
target_value = target_dict.get(key)
if force_delegate or is_equal(value, target_value):
del new_dict[key]
......@@ -1086,7 +1087,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
getFieldDict(target_field, 'tales'))
if target_field.meta_type=='ProxyField':
for i in new_values.keys():
for i in ensure_list(new_values.keys()):
if not i in target_field.delegated_list:
# obsolete variable check
try:
......@@ -1098,7 +1099,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
if is_equal(target_field.get_recursive_orig_value(i),
new_values[i]):
del new_values[i]
for i in new_tales.keys():
for i in ensure_list(new_tales.keys()):
if not i in target_field.delegated_list:
# obsolete variable check
try:
......@@ -1159,7 +1160,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
return a==b
def remove_same_value(new_dict, target_dict):
for key, value in new_dict.items():
for key, value in ensure_list(new_dict.items()):
target_value = target_dict.get(key)
if is_equal(value, target_value):
del new_dict[key]
......
......@@ -38,8 +38,7 @@ from Products.Formulator.Field import ZMIField
from Products.Formulator.Errors import FormValidationError, ValidationError
from .Selection import Selection, DomainSelection
from .Tool.SelectionTool import createFolderMixInPageSelectionMethod
from Products.ERP5Type.Utils import getPath
from Products.ERP5Type.Utils import UpperCase
from Products.ERP5Type.Utils import UpperCase, ensure_list, getPath
from Products.ERP5Type.Document import newTempBase
from Products.CMFCore.utils import getToolByName
from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain
......@@ -106,7 +105,7 @@ class CatalogMethodWrapper(MethodWrapper):
# XXX: I'm not sure if this filtering really belongs to here.
# It is probably needed at a more generic level (Forms ? Selection ?), or
# even a more specific one (limited to HTML ?)...
for key, value in kw.items():
for key, value in ensure_list(kw.items()):
if value == '':
kw.pop(key)
return getattr(self.context, self.method_name)(*args, **kw)
......
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