Status: | Merged |
---|---|
Merged at revision: | 514 |
Proposed branch: | lp:~cjwatson/storm/py3-dict |
Merge into: | lp:storm |
Diff against target: |
385 lines (+49/-31) 14 files modified
storm/cache.py (+6/-3) storm/cextensions.c (+1/-1) storm/expr.py (+1/-1) storm/info.py (+3/-1) storm/references.py (+4/-2) storm/sqlobject.py (+6/-4) storm/store.py (+3/-3) storm/tz.py (+3/-1) storm/uri.py (+2/-1) storm/zope/testing.py (+4/-2) storm/zope/zstorm.py (+4/-3) tests/mocker.py (+8/-7) tests/store/base.py (+1/-1) tests/zope/testing.py (+3/-1) |
To merge this branch: | bzr merge lp:~cjwatson/storm/py3-dict |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kristian Glass (community) | Approve | ||
Storm Developers | Pending | ||
Review via email: mp+371160@code.launchpad.net |
Commit message
Handle Python 3's changes to dict iteration methods.
Description of the change
In most cases I opted for a somewhat pedantic translation of d.iterfoo() to six.iterfoo(d) and d.foo() to list(six.
There were a few cases where the Python 2 code was iterating over something like d.items() when it didn't need to do a copy; I left those cases alone, since they'll just become slightly more efficient under Python 3.
To post a comment you must log in.
Revision history for this message
Kristian Glass (doismellburning) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'storm/cache.py' | |||
2 | --- storm/cache.py 2019-06-05 11:41:07 +0000 | |||
3 | +++ storm/cache.py 2019-08-11 09:53:43 +0000 | |||
4 | @@ -2,6 +2,8 @@ | |||
5 | 2 | 2 | ||
6 | 3 | import itertools | 3 | import itertools |
7 | 4 | 4 | ||
8 | 5 | import six | ||
9 | 6 | |||
10 | 5 | 7 | ||
11 | 6 | class Cache(object): | 8 | class Cache(object): |
12 | 7 | """Prevents recently used objects from being deallocated. | 9 | """Prevents recently used objects from being deallocated. |
13 | @@ -142,9 +144,10 @@ | |||
14 | 142 | objects, but no more than twice that number. | 144 | objects, but no more than twice that number. |
15 | 143 | """ | 145 | """ |
16 | 144 | self._size = size | 146 | self._size = size |
20 | 145 | cache = itertools.islice(itertools.chain(self._new_cache.iteritems(), | 147 | cache = itertools.islice( |
21 | 146 | self._old_cache.iteritems()), | 148 | itertools.chain(six.iteritems(self._new_cache), |
22 | 147 | 0, size) | 149 | six.iteritems(self._old_cache)), |
23 | 150 | 0, size) | ||
24 | 148 | self._new_cache = dict(cache) | 151 | self._new_cache = dict(cache) |
25 | 149 | self._old_cache.clear() | 152 | self._old_cache.clear() |
26 | 150 | 153 | ||
27 | 151 | 154 | ||
28 | === modified file 'storm/cextensions.c' | |||
29 | --- storm/cextensions.c 2019-06-19 09:34:36 +0000 | |||
30 | +++ storm/cextensions.c 2019-08-11 09:53:43 +0000 | |||
31 | @@ -1931,7 +1931,7 @@ | |||
32 | 1931 | PyObject *column, *variable, *tmp; | 1931 | PyObject *column, *variable, *tmp; |
33 | 1932 | Py_ssize_t i = 0; | 1932 | Py_ssize_t i = 0; |
34 | 1933 | 1933 | ||
36 | 1934 | /* for variable in self.variables.itervalues(): */ | 1934 | /* for variable in six.itervalues(self.variables): */ |
37 | 1935 | while (PyDict_Next(self->variables, &i, &column, &variable)) { | 1935 | while (PyDict_Next(self->variables, &i, &column, &variable)) { |
38 | 1936 | /* variable.checkpoint() */ | 1936 | /* variable.checkpoint() */ |
39 | 1937 | CATCH(NULL, tmp = PyObject_CallMethod(variable, "checkpoint", NULL)); | 1937 | CATCH(NULL, tmp = PyObject_CallMethod(variable, "checkpoint", NULL)); |
40 | 1938 | 1938 | ||
41 | === modified file 'storm/expr.py' | |||
42 | --- storm/expr.py 2019-06-07 16:36:44 +0000 | |||
43 | +++ storm/expr.py 2019-08-11 09:53:43 +0000 | |||
44 | @@ -740,7 +740,7 @@ | |||
45 | 740 | state.context = EXPR | 740 | state.context = EXPR |
46 | 741 | values = insert.values | 741 | values = insert.values |
47 | 742 | if values is Undef: | 742 | if values is Undef: |
49 | 743 | values = [tuple(insert.map.itervalues())] | 743 | values = [tuple(six.itervalues(insert.map))] |
50 | 744 | if isinstance(values, Expr): | 744 | if isinstance(values, Expr): |
51 | 745 | compiled_values = compile(values, state) | 745 | compiled_values = compile(values, state) |
52 | 746 | else: | 746 | else: |
53 | 747 | 747 | ||
54 | === modified file 'storm/info.py' | |||
55 | --- storm/info.py 2019-06-05 11:41:07 +0000 | |||
56 | +++ storm/info.py 2019-08-11 09:53:43 +0000 | |||
57 | @@ -22,6 +22,8 @@ | |||
58 | 22 | 22 | ||
59 | 23 | from weakref import ref | 23 | from weakref import ref |
60 | 24 | 24 | ||
61 | 25 | import six | ||
62 | 26 | |||
63 | 25 | from storm.exceptions import ClassInfoError | 27 | from storm.exceptions import ClassInfoError |
64 | 26 | from storm.expr import Column, Desc, TABLE | 28 | from storm.expr import Column, Desc, TABLE |
65 | 27 | from storm.expr import compile, Table | 29 | from storm.expr import compile, Table |
66 | @@ -194,7 +196,7 @@ | |||
67 | 194 | self.event.emit("object-deleted") | 196 | self.event.emit("object-deleted") |
68 | 195 | 197 | ||
69 | 196 | def checkpoint(self): | 198 | def checkpoint(self): |
71 | 197 | for variable in self.variables.itervalues(): | 199 | for variable in six.itervalues(self.variables): |
72 | 198 | variable.checkpoint() | 200 | variable.checkpoint() |
73 | 199 | 201 | ||
74 | 200 | 202 | ||
75 | 201 | 203 | ||
76 | === modified file 'storm/references.py' | |||
77 | --- storm/references.py 2019-06-05 11:41:07 +0000 | |||
78 | +++ storm/references.py 2019-08-11 09:53:43 +0000 | |||
79 | @@ -22,6 +22,8 @@ | |||
80 | 22 | 22 | ||
81 | 23 | import weakref | 23 | import weakref |
82 | 24 | 24 | ||
83 | 25 | import six | ||
84 | 26 | |||
85 | 25 | from storm.exceptions import ( | 27 | from storm.exceptions import ( |
86 | 26 | ClassInfoError, FeatureError, NoStoreError, WrongStoreError) | 28 | ClassInfoError, FeatureError, NoStoreError, WrongStoreError) |
87 | 27 | from storm.store import Store, get_where_for_args, LostObjectError | 29 | from storm.store import Store, get_where_for_args, LostObjectError |
88 | @@ -940,14 +942,14 @@ | |||
89 | 940 | 942 | ||
90 | 941 | def _find_descriptor_class(used_cls, descr): | 943 | def _find_descriptor_class(used_cls, descr): |
91 | 942 | for cls in used_cls.__mro__: | 944 | for cls in used_cls.__mro__: |
93 | 943 | for attr, _descr in cls.__dict__.iteritems(): | 945 | for attr, _descr in six.iteritems(cls.__dict__): |
94 | 944 | if _descr is descr: | 946 | if _descr is descr: |
95 | 945 | return cls | 947 | return cls |
96 | 946 | raise RuntimeError("Reference used in an unknown class") | 948 | raise RuntimeError("Reference used in an unknown class") |
97 | 947 | 949 | ||
98 | 948 | def _find_descriptor_obj(used_cls, descr): | 950 | def _find_descriptor_obj(used_cls, descr): |
99 | 949 | for cls in used_cls.__mro__: | 951 | for cls in used_cls.__mro__: |
101 | 950 | for attr, _descr in cls.__dict__.iteritems(): | 952 | for attr, _descr in six.iteritems(cls.__dict__): |
102 | 951 | if _descr is descr: | 953 | if _descr is descr: |
103 | 952 | return getattr(cls, attr) | 954 | return getattr(cls, attr) |
104 | 953 | raise RuntimeError("Reference used in an unknown class") | 955 | raise RuntimeError("Reference used in an unknown class") |
105 | 954 | 956 | ||
106 | === modified file 'storm/sqlobject.py' | |||
107 | --- storm/sqlobject.py 2019-06-05 11:41:07 +0000 | |||
108 | +++ storm/sqlobject.py 2019-08-11 09:53:43 +0000 | |||
109 | @@ -28,6 +28,8 @@ | |||
110 | 28 | import re | 28 | import re |
111 | 29 | import warnings | 29 | import warnings |
112 | 30 | 30 | ||
113 | 31 | import six | ||
114 | 32 | |||
115 | 31 | from storm.properties import ( | 33 | from storm.properties import ( |
116 | 32 | RawStr, Int, Bool, Float, DateTime, Date, TimeDelta) | 34 | RawStr, Int, Bool, Float, DateTime, Date, TimeDelta) |
117 | 33 | from storm.references import Reference, ReferenceSet | 35 | from storm.references import Reference, ReferenceSet |
118 | @@ -164,7 +166,7 @@ | |||
119 | 164 | dict["__storm_table__"] = table_name | 166 | dict["__storm_table__"] = table_name |
120 | 165 | 167 | ||
121 | 166 | attr_to_prop = {} | 168 | attr_to_prop = {} |
123 | 167 | for attr, prop in dict.items(): | 169 | for attr, prop in list(six.iteritems(dict)): |
124 | 168 | attr_to_prop[attr] = attr | 170 | attr_to_prop[attr] = attr |
125 | 169 | if isinstance(prop, ForeignKey): | 171 | if isinstance(prop, ForeignKey): |
126 | 170 | db_name = prop.kwargs.get("dbName", attr) | 172 | db_name = prop.kwargs.get("dbName", attr) |
127 | @@ -224,7 +226,7 @@ | |||
128 | 224 | property_registry.add_property(obj, getattr(obj, "id"), | 226 | property_registry.add_property(obj, getattr(obj, "id"), |
129 | 225 | "<table %s>" % table_name) | 227 | "<table %s>" % table_name) |
130 | 226 | 228 | ||
132 | 227 | for fake_name, real_name in attr_to_prop.items(): | 229 | for fake_name, real_name in list(six.iteritems(attr_to_prop)): |
133 | 228 | prop = getattr(obj, real_name) | 230 | prop = getattr(obj, real_name) |
134 | 229 | if fake_name != real_name: | 231 | if fake_name != real_name: |
135 | 230 | property_registry.add_property(obj, prop, fake_name) | 232 | property_registry.add_property(obj, prop, fake_name) |
136 | @@ -298,7 +300,7 @@ | |||
137 | 298 | self._init(None) | 300 | self._init(None) |
138 | 299 | 301 | ||
139 | 300 | def set(self, **kwargs): | 302 | def set(self, **kwargs): |
141 | 301 | for attr, value in kwargs.iteritems(): | 303 | for attr, value in six.iteritems(kwargs): |
142 | 302 | setattr(self, attr, value) | 304 | setattr(self, attr, value) |
143 | 303 | 305 | ||
144 | 304 | def destroySelf(self): | 306 | def destroySelf(self): |
145 | @@ -406,7 +408,7 @@ | |||
146 | 406 | 408 | ||
147 | 407 | def _copy(self, **kwargs): | 409 | def _copy(self, **kwargs): |
148 | 408 | copy = self.__class__(self._cls, **kwargs) | 410 | copy = self.__class__(self._cls, **kwargs) |
150 | 409 | for name, value in self.__dict__.iteritems(): | 411 | for name, value in six.iteritems(self.__dict__): |
151 | 410 | if name[1:] not in kwargs and name != "_finished_result_set": | 412 | if name[1:] not in kwargs and name != "_finished_result_set": |
152 | 411 | setattr(copy, name, value) | 413 | setattr(copy, name, value) |
153 | 412 | return copy | 414 | return copy |
154 | 413 | 415 | ||
155 | === modified file 'storm/store.py' | |||
156 | --- storm/store.py 2019-06-05 11:41:07 +0000 | |||
157 | +++ storm/store.py 2019-08-11 09:53:43 +0000 | |||
158 | @@ -474,7 +474,7 @@ | |||
159 | 474 | self._dirty = flushing | 474 | self._dirty = flushing |
160 | 475 | 475 | ||
161 | 476 | predecessors = {} | 476 | predecessors = {} |
163 | 477 | for (before_info, after_info), n in self._order.iteritems(): | 477 | for (before_info, after_info), n in six.iteritems(self._order): |
164 | 478 | if n > 0: | 478 | if n > 0: |
165 | 479 | before_set = predecessors.get(after_info) | 479 | before_set = predecessors.get(after_info) |
166 | 480 | if before_set is None: | 480 | if before_set is None: |
167 | @@ -853,7 +853,7 @@ | |||
168 | 853 | del obj_info["primary_vars"] | 853 | del obj_info["primary_vars"] |
169 | 854 | 854 | ||
170 | 855 | def _iter_alive(self): | 855 | def _iter_alive(self): |
172 | 856 | return self._alive.values() | 856 | return list(six.itervalues(self._alive)) |
173 | 857 | 857 | ||
174 | 858 | def _enable_change_notification(self, obj_info): | 858 | def _enable_change_notification(self, obj_info): |
175 | 859 | obj_info.event.emit("start-tracking-changes", self._event) | 859 | obj_info.event.emit("start-tracking-changes", self._event) |
176 | @@ -1406,7 +1406,7 @@ | |||
177 | 1406 | for column in changes: | 1406 | for column in changes: |
178 | 1407 | obj_info.variables[column].set(AutoReload) | 1407 | obj_info.variables[column].set(AutoReload) |
179 | 1408 | else: | 1408 | else: |
181 | 1409 | changes = changes.items() | 1409 | changes = list(six.iteritems(changes)) |
182 | 1410 | for obj in cached: | 1410 | for obj in cached: |
183 | 1411 | for column, value in changes: | 1411 | for column, value in changes: |
184 | 1412 | variables = get_obj_info(obj).variables | 1412 | variables = get_obj_info(obj).variables |
185 | 1413 | 1413 | ||
186 | === modified file 'storm/tz.py' | |||
187 | --- storm/tz.py 2019-08-09 13:09:09 +0000 | |||
188 | +++ storm/tz.py 2019-08-11 09:53:43 +0000 | |||
189 | @@ -15,6 +15,8 @@ | |||
190 | 15 | import sys | 15 | import sys |
191 | 16 | import os | 16 | import os |
192 | 17 | 17 | ||
193 | 18 | import six | ||
194 | 19 | |||
195 | 18 | relativedelta = None | 20 | relativedelta = None |
196 | 19 | parser = None | 21 | parser = None |
197 | 20 | rrule = None | 22 | rrule = None |
198 | @@ -714,7 +716,7 @@ | |||
199 | 714 | 716 | ||
200 | 715 | def get(self, tzid=None): | 717 | def get(self, tzid=None): |
201 | 716 | if tzid is None: | 718 | if tzid is None: |
203 | 717 | keys = self._vtz.keys() | 719 | keys = list(six.iterkeys(self._vtz)) |
204 | 718 | if len(keys) == 0: | 720 | if len(keys) == 0: |
205 | 719 | raise Exception("no timezones defined") | 721 | raise Exception("no timezones defined") |
206 | 720 | elif len(keys) > 1: | 722 | elif len(keys) > 1: |
207 | 721 | 723 | ||
208 | === modified file 'storm/uri.py' | |||
209 | --- storm/uri.py 2019-06-07 17:14:33 +0000 | |||
210 | +++ storm/uri.py 2019-08-11 09:53:43 +0000 | |||
211 | @@ -20,6 +20,7 @@ | |||
212 | 20 | # | 20 | # |
213 | 21 | from __future__ import print_function | 21 | from __future__ import print_function |
214 | 22 | 22 | ||
215 | 23 | import six | ||
216 | 23 | from six.moves.urllib.parse import quote | 24 | from six.moves.urllib.parse import quote |
217 | 24 | 25 | ||
218 | 25 | from storm.exceptions import URIError | 26 | from storm.exceptions import URIError |
219 | @@ -104,7 +105,7 @@ | |||
220 | 104 | append(escape(self.database, "/")) | 105 | append(escape(self.database, "/")) |
221 | 105 | if self.options: | 106 | if self.options: |
222 | 106 | options = ["%s=%s" % (escape(key), escape(value)) | 107 | options = ["%s=%s" % (escape(key), escape(value)) |
224 | 107 | for key, value in sorted(self.options.iteritems())] | 108 | for key, value in sorted(six.iteritems(self.options))] |
225 | 108 | append("?") | 109 | append("?") |
226 | 109 | append("&".join(options)) | 110 | append("&".join(options)) |
227 | 110 | return "".join(tokens) | 111 | return "".join(tokens) |
228 | 111 | 112 | ||
229 | === modified file 'storm/zope/testing.py' | |||
230 | --- storm/zope/testing.py 2019-06-05 11:41:07 +0000 | |||
231 | +++ storm/zope/testing.py 2019-08-11 09:53:43 +0000 | |||
232 | @@ -23,6 +23,7 @@ | |||
233 | 23 | import os | 23 | import os |
234 | 24 | import shutil | 24 | import shutil |
235 | 25 | 25 | ||
236 | 26 | import six | ||
237 | 26 | import transaction | 27 | import transaction |
238 | 27 | 28 | ||
239 | 28 | from testresources import TestResourceManager | 29 | from testresources import TestResourceManager |
240 | @@ -99,8 +100,9 @@ | |||
241 | 99 | # Adapt the old databases format to the new one, for backward | 100 | # Adapt the old databases format to the new one, for backward |
242 | 100 | # compatibility. This should be eventually dropped. | 101 | # compatibility. This should be eventually dropped. |
243 | 101 | if isinstance(databases, dict): | 102 | if isinstance(databases, dict): |
246 | 102 | databases = [{"name": name, "uri": uri, "schema": schema} | 103 | databases = [ |
247 | 103 | for name, (uri, schema) in databases.iteritems()] | 104 | {"name": name, "uri": uri, "schema": schema} |
248 | 105 | for name, (uri, schema) in six.iteritems(databases)] | ||
249 | 104 | 106 | ||
250 | 105 | # Provide the global IZStorm utility before applying patches, so | 107 | # Provide the global IZStorm utility before applying patches, so |
251 | 106 | # patch code can get the ztorm object if needed (e.g. looking up | 108 | # patch code can get the ztorm object if needed (e.g. looking up |
252 | 107 | 109 | ||
253 | === modified file 'storm/zope/zstorm.py' | |||
254 | --- storm/zope/zstorm.py 2019-06-06 10:14:55 +0000 | |||
255 | +++ storm/zope/zstorm.py 2019-08-11 09:53:43 +0000 | |||
256 | @@ -31,6 +31,7 @@ | |||
257 | 31 | 31 | ||
258 | 32 | from uuid import uuid4 | 32 | from uuid import uuid4 |
259 | 33 | 33 | ||
260 | 34 | import six | ||
261 | 34 | from zope.interface import implementer | 35 | from zope.interface import implementer |
262 | 35 | 36 | ||
263 | 36 | import transaction | 37 | import transaction |
264 | @@ -206,11 +207,11 @@ | |||
265 | 206 | 207 | ||
266 | 207 | def iterstores(self): | 208 | def iterstores(self): |
267 | 208 | """Iterate C{name, store} 2-tuples.""" | 209 | """Iterate C{name, store} 2-tuples.""" |
270 | 209 | # items is explicitly used here, instead of iteritems, to | 210 | # We explicitly copy the list of items before iterating over |
271 | 210 | # avoid the problem where a store is deallocated during | 211 | # it to avoid the problem where a store is deallocated during |
272 | 211 | # iteration causing RuntimeError: dictionary changed size | 212 | # iteration causing RuntimeError: dictionary changed size |
273 | 212 | # during iteration. | 213 | # during iteration. |
275 | 213 | for store, name in self._name_index.items(): | 214 | for store, name in list(six.iteritems(self._name_index)): |
276 | 214 | yield name, store | 215 | yield name, store |
277 | 215 | 216 | ||
278 | 216 | def get_name(self, store): | 217 | def get_name(self, store): |
279 | 217 | 218 | ||
280 | === modified file 'tests/mocker.py' | |||
281 | --- tests/mocker.py 2019-06-07 17:14:33 +0000 | |||
282 | +++ tests/mocker.py 2019-08-11 09:53:43 +0000 | |||
283 | @@ -13,6 +13,7 @@ | |||
284 | 13 | import os | 13 | import os |
285 | 14 | import gc | 14 | import gc |
286 | 15 | 15 | ||
287 | 16 | import six | ||
288 | 16 | from six.moves import builtins | 17 | from six.moves import builtins |
289 | 17 | 18 | ||
290 | 18 | 19 | ||
291 | @@ -1109,13 +1110,13 @@ | |||
292 | 1109 | frame = sys._getframe(depth+1) | 1110 | frame = sys._getframe(depth+1) |
293 | 1110 | except: | 1111 | except: |
294 | 1111 | return None | 1112 | return None |
296 | 1112 | for name, frame_obj in frame.f_locals.iteritems(): | 1113 | for name, frame_obj in six.iteritems(frame.f_locals): |
297 | 1113 | if frame_obj is obj: | 1114 | if frame_obj is obj: |
298 | 1114 | return name | 1115 | return name |
299 | 1115 | self = frame.f_locals.get("self") | 1116 | self = frame.f_locals.get("self") |
300 | 1116 | if self is not None: | 1117 | if self is not None: |
301 | 1117 | try: | 1118 | try: |
303 | 1118 | items = list(self.__dict__.iteritems()) | 1119 | items = list(six.iteritems(self.__dict__)) |
304 | 1119 | except: | 1120 | except: |
305 | 1120 | pass | 1121 | pass |
306 | 1121 | else: | 1122 | else: |
307 | @@ -1264,7 +1265,7 @@ | |||
308 | 1264 | result = "del %s.%s" % (result, action.args[0]) | 1265 | result = "del %s.%s" % (result, action.args[0]) |
309 | 1265 | elif action.kind == "call": | 1266 | elif action.kind == "call": |
310 | 1266 | args = [repr(x) for x in action.args] | 1267 | args = [repr(x) for x in action.args] |
312 | 1267 | items = list(action.kwargs.iteritems()) | 1268 | items = list(six.iteritems(action.kwargs)) |
313 | 1268 | items.sort() | 1269 | items.sort() |
314 | 1269 | for pair in items: | 1270 | for pair in items: |
315 | 1270 | args.append("%s=%r" % pair) | 1271 | args.append("%s=%r" % pair) |
316 | @@ -1384,7 +1385,7 @@ | |||
317 | 1384 | 1385 | ||
318 | 1385 | # Either we have the same number of kwargs, or unknown keywords are | 1386 | # Either we have the same number of kwargs, or unknown keywords are |
319 | 1386 | # accepted (KWARGS was used), so check just the ones in kwargs1. | 1387 | # accepted (KWARGS was used), so check just the ones in kwargs1. |
321 | 1387 | for key, arg1 in kwargs1.iteritems(): | 1388 | for key, arg1 in six.iteritems(kwargs1): |
322 | 1388 | if key not in kwargs2: | 1389 | if key not in kwargs2: |
323 | 1389 | return False | 1390 | return False |
324 | 1390 | arg2 = kwargs2[key] | 1391 | arg2 = kwargs2[key] |
325 | @@ -1914,7 +1915,7 @@ | |||
326 | 1914 | for referrer in gc.get_referrers(remove): | 1915 | for referrer in gc.get_referrers(remove): |
327 | 1915 | if (type(referrer) is dict and | 1916 | if (type(referrer) is dict and |
328 | 1916 | referrer.get("__mocker_replace__", True)): | 1917 | referrer.get("__mocker_replace__", True)): |
330 | 1917 | for key, value in referrer.items(): | 1918 | for key, value in list(six.iteritems(referrer)): |
331 | 1918 | if value is remove: | 1919 | if value is remove: |
332 | 1919 | referrer[key] = install | 1920 | referrer[key] = install |
333 | 1920 | 1921 | ||
334 | @@ -1986,7 +1987,7 @@ | |||
335 | 1986 | for kind in self._monitored: | 1987 | for kind in self._monitored: |
336 | 1987 | attr = self._get_kind_attr(kind) | 1988 | attr = self._get_kind_attr(kind) |
337 | 1988 | seen = set() | 1989 | seen = set() |
339 | 1989 | for obj in self._monitored[kind].itervalues(): | 1990 | for obj in six.itervalues(self._monitored[kind]): |
340 | 1990 | cls = type(obj) | 1991 | cls = type(obj) |
341 | 1991 | if issubclass(cls, type): | 1992 | if issubclass(cls, type): |
342 | 1992 | cls = obj | 1993 | cls = obj |
343 | @@ -2000,7 +2001,7 @@ | |||
344 | 2000 | self.execute) | 2001 | self.execute) |
345 | 2001 | 2002 | ||
346 | 2002 | def restore(self): | 2003 | def restore(self): |
348 | 2003 | for obj, attr, original in self._patched.itervalues(): | 2004 | for obj, attr, original in six.itervalues(self._patched): |
349 | 2004 | if original is Undefined: | 2005 | if original is Undefined: |
350 | 2005 | delattr(obj, attr) | 2006 | delattr(obj, attr) |
351 | 2006 | else: | 2007 | else: |
352 | 2007 | 2008 | ||
353 | === modified file 'tests/store/base.py' | |||
354 | --- tests/store/base.py 2019-06-07 17:14:33 +0000 | |||
355 | +++ tests/store/base.py 2019-08-11 09:53:43 +0000 | |||
356 | @@ -4946,7 +4946,7 @@ | |||
357 | 4946 | foo = self.store.get(DictFoo, 20) | 4946 | foo = self.store.get(DictFoo, 20) |
358 | 4947 | foo["a"] = 1 | 4947 | foo["a"] = 1 |
359 | 4948 | 4948 | ||
361 | 4949 | self.assertEquals(foo.items(), [("a", 1)]) | 4949 | self.assertEquals(list(six.iteritems(foo)), [("a", 1)]) |
362 | 4950 | 4950 | ||
363 | 4951 | new_obj = DictFoo() | 4951 | new_obj = DictFoo() |
364 | 4952 | new_obj.id = 40 | 4952 | new_obj.id = 40 |
365 | 4953 | 4953 | ||
366 | === modified file 'tests/zope/testing.py' | |||
367 | --- tests/zope/testing.py 2019-06-05 11:41:07 +0000 | |||
368 | +++ tests/zope/testing.py 2019-08-11 09:53:43 +0000 | |||
369 | @@ -23,6 +23,8 @@ | |||
370 | 23 | import os | 23 | import os |
371 | 24 | import sys | 24 | import sys |
372 | 25 | 25 | ||
373 | 26 | import six | ||
374 | 27 | |||
375 | 26 | from tests.helper import TestHelper | 28 | from tests.helper import TestHelper |
376 | 27 | from tests.zope import has_transaction, has_zope_component, has_testresources | 29 | from tests.zope import has_transaction, has_zope_component, has_testresources |
377 | 28 | 30 | ||
378 | @@ -239,7 +241,7 @@ | |||
379 | 239 | real_invalidate = store.invalidate | 241 | real_invalidate = store.invalidate |
380 | 240 | 242 | ||
381 | 241 | def invalidate_proxy(): | 243 | def invalidate_proxy(): |
383 | 242 | self.assertEqual(0, len(store._alive.values())) | 244 | self.assertEqual(0, len(list(six.itervalues(store._alive)))) |
384 | 243 | real_invalidate() | 245 | real_invalidate() |
385 | 244 | store.invalidate = invalidate_proxy | 246 | store.invalidate = invalidate_proxy |
386 | 245 | 247 |