Merge lp:~cjwatson/lazr.restful/py3-dict-methods into lp:lazr.restful
- py3-dict-methods
- Merge into trunk
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 248 |
Proposed branch: | lp:~cjwatson/lazr.restful/py3-dict-methods |
Merge into: | lp:lazr.restful |
Diff against target: |
202 lines (+22/-22) 10 files modified
src/lazr/restful/_resource.py (+3/-3) src/lazr/restful/declarations.py (+2/-2) src/lazr/restful/docs/webservice-declarations.rst (+1/-1) src/lazr/restful/docs/webservice-marshallers.rst (+1/-1) src/lazr/restful/docs/webservice.rst (+2/-3) src/lazr/restful/example/base/tests/representation-cache.txt (+6/-5) src/lazr/restful/metazcml.py (+1/-1) src/lazr/restful/simple.py (+1/-1) src/lazr/restful/tales.py (+1/-1) src/lazr/restful/tests/test_declarations.py (+4/-4) |
To merge this branch: | bzr merge lp:~cjwatson/lazr.restful/py3-dict-methods |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+387905@code.launchpad.net |
Commit message
Handle dict method changes in Python 3.
Description of the change
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/lazr/restful/_resource.py' | |||
2 | --- src/lazr/restful/_resource.py 2020-06-30 15:52:03 +0000 | |||
3 | +++ src/lazr/restful/_resource.py 2020-07-22 23:32:54 +0000 | |||
4 | @@ -1221,7 +1221,7 @@ | |||
5 | 1221 | # The changeset contained new values for some of this object's | 1221 | # The changeset contained new values for some of this object's |
6 | 1222 | # fields, and the notification event may have changed others. | 1222 | # fields, and the notification event may have changed others. |
7 | 1223 | # Clear out any fields that changed. | 1223 | # Clear out any fields that changed. |
9 | 1224 | for name, cached in self._unmarshalled_field_cache.items(): | 1224 | for name, cached in list(self._unmarshalled_field_cache.items()): |
10 | 1225 | cached, (field, old_value, flag) = cached | 1225 | cached, (field, old_value, flag) = cached |
11 | 1226 | if flag is IUnmarshallingDoesntNeedValue: | 1226 | if flag is IUnmarshallingDoesntNeedValue: |
12 | 1227 | continue | 1227 | continue |
13 | @@ -1986,14 +1986,14 @@ | |||
14 | 1986 | schema, self.request) | 1986 | schema, self.request) |
15 | 1987 | 1987 | ||
16 | 1988 | singular = adapter.singular_type | 1988 | singular = adapter.singular_type |
18 | 1989 | assert not singular_names.has_key(singular), ( | 1989 | assert singular not in singular_names, ( |
19 | 1990 | "Both %s and %s expose the singular name '%s'." | 1990 | "Both %s and %s expose the singular name '%s'." |
20 | 1991 | % (singular_names[singular].__name__, | 1991 | % (singular_names[singular].__name__, |
21 | 1992 | schema.__name__, singular)) | 1992 | schema.__name__, singular)) |
22 | 1993 | singular_names[singular] = schema | 1993 | singular_names[singular] = schema |
23 | 1994 | 1994 | ||
24 | 1995 | plural = adapter.plural_type | 1995 | plural = adapter.plural_type |
26 | 1996 | assert not plural_names.has_key(plural), ( | 1996 | assert plural not in plural_names, ( |
27 | 1997 | "Both %s and %s expose the plural name '%s'." | 1997 | "Both %s and %s expose the plural name '%s'." |
28 | 1998 | % (plural_names[plural].__name__, | 1998 | % (plural_names[plural].__name__, |
29 | 1999 | schema.__name__, plural)) | 1999 | schema.__name__, plural)) |
30 | 2000 | 2000 | ||
31 | === modified file 'src/lazr/restful/declarations.py' | |||
32 | --- src/lazr/restful/declarations.py 2020-02-05 10:46:46 +0000 | |||
33 | +++ src/lazr/restful/declarations.py 2020-07-22 23:32:54 +0000 | |||
34 | @@ -405,7 +405,7 @@ | |||
35 | 405 | # If any keywords are left over, raise an exception. | 405 | # If any keywords are left over, raise an exception. |
36 | 406 | if len(kwparams) > 0: | 406 | if len(kwparams) > 0: |
37 | 407 | raise TypeError("exported got an unexpected keyword " | 407 | raise TypeError("exported got an unexpected keyword " |
39 | 408 | "argument '%s'" % kwparams.keys()[0]) | 408 | "argument '%s'" % list(kwparams)[0]) |
40 | 409 | 409 | ||
41 | 410 | # Now incorporate the list of named dicts into the VersionedDict. | 410 | # Now incorporate the list of named dicts into the VersionedDict. |
42 | 411 | for version, annotations in reversed(versioned_annotations): | 411 | for version, annotations in reversed(versioned_annotations): |
43 | @@ -1254,7 +1254,7 @@ | |||
44 | 1254 | # Go through the fields and build up a picture of what this entry looks | 1254 | # Go through the fields and build up a picture of what this entry looks |
45 | 1255 | # like for every version. | 1255 | # like for every version. |
46 | 1256 | adapters_by_version = {} | 1256 | adapters_by_version = {} |
48 | 1257 | fields = getFields(content_interface).items() | 1257 | fields = list(getFields(content_interface).items()) |
49 | 1258 | for version, iface in webservice_interfaces: | 1258 | for version, iface in webservice_interfaces: |
50 | 1259 | fields.extend(getFields(iface).items()) | 1259 | fields.extend(getFields(iface).items()) |
51 | 1260 | for name, field in fields: | 1260 | for name, field in fields: |
52 | 1261 | 1261 | ||
53 | === modified file 'src/lazr/restful/docs/webservice-declarations.rst' | |||
54 | --- src/lazr/restful/docs/webservice-declarations.rst 2020-06-30 13:33:53 +0000 | |||
55 | +++ src/lazr/restful/docs/webservice-declarations.rst 2020-07-22 23:32:54 +0000 | |||
56 | @@ -2352,7 +2352,7 @@ | |||
57 | 2352 | 2352 | ||
58 | 2353 | >>> attrs['params']['arg'] | 2353 | >>> attrs['params']['arg'] |
59 | 2354 | <zope.schema._field.Float object...> | 2354 | <zope.schema._field.Float object...> |
61 | 2355 | >>> attrs['params'].keys() | 2355 | >>> list(attrs['params']) |
62 | 2356 | ['arg'] | 2356 | ['arg'] |
63 | 2357 | 2357 | ||
64 | 2358 | >>> attrs['return_type'] | 2358 | >>> attrs['return_type'] |
65 | 2359 | 2359 | ||
66 | === modified file 'src/lazr/restful/docs/webservice-marshallers.rst' | |||
67 | --- src/lazr/restful/docs/webservice-marshallers.rst 2020-06-30 15:52:03 +0000 | |||
68 | +++ src/lazr/restful/docs/webservice-marshallers.rst 2020-07-22 23:32:54 +0000 | |||
69 | @@ -928,7 +928,7 @@ | |||
70 | 928 | ['Dessert', 'Vegetarian'] | 928 | ['Dessert', 'Vegetarian'] |
71 | 929 | 929 | ||
72 | 930 | >>> unmarshalled = dict_marshaller.unmarshall(None, marshalled_dict) | 930 | >>> unmarshalled = dict_marshaller.unmarshall(None, marshalled_dict) |
74 | 931 | >>> sorted(unmarshalled.iteritems()) | 931 | >>> sorted(unmarshalled.items()) |
75 | 932 | [(u'bar', 'General'), (u'foo', 'Vegetarian')] | 932 | [(u'bar', 'General'), (u'foo', 'Vegetarian')] |
76 | 933 | 933 | ||
77 | 934 | The unmarshall() method will return None when given None. | 934 | The unmarshall() method will return None when given None. |
78 | 935 | 935 | ||
79 | === modified file 'src/lazr/restful/docs/webservice.rst' | |||
80 | --- src/lazr/restful/docs/webservice.rst 2020-02-04 13:17:32 +0000 | |||
81 | +++ src/lazr/restful/docs/webservice.rst 2020-07-22 23:32:54 +0000 | |||
82 | @@ -652,10 +652,9 @@ | |||
83 | 652 | >>> from lazr.restful import Entry | 652 | >>> from lazr.restful import Entry |
84 | 653 | >>> from lazr.restful.testing.webservice import FakeRequest | 653 | >>> from lazr.restful.testing.webservice import FakeRequest |
85 | 654 | 654 | ||
88 | 655 | >>> from UserDict import UserDict | 655 | >>> class FakeDict(dict): |
87 | 656 | >>> class FakeDict(UserDict): | ||
89 | 657 | ... def __init__(self, interface): | 656 | ... def __init__(self, interface): |
91 | 658 | ... UserDict.__init__(self) | 657 | ... super(FakeDict, self).__init__() |
92 | 659 | ... self.interface = interface | 658 | ... self.interface = interface |
93 | 660 | ... def __getitem__(self, key): | 659 | ... def __getitem__(self, key): |
94 | 661 | ... return self.interface | 660 | ... return self.interface |
95 | 662 | 661 | ||
96 | === modified file 'src/lazr/restful/example/base/tests/representation-cache.txt' | |||
97 | --- src/lazr/restful/example/base/tests/representation-cache.txt 2020-02-04 13:17:32 +0000 | |||
98 | +++ src/lazr/restful/example/base/tests/representation-cache.txt 2020-07-22 23:32:54 +0000 | |||
99 | @@ -94,8 +94,9 @@ | |||
100 | 94 | 94 | ||
101 | 95 | >>> test_cache.set("Cache this.", json, "1.0", "representation") | 95 | >>> test_cache.set("Cache this.", json, "1.0", "representation") |
102 | 96 | >>> test_cache.set("Don't cache this.", json, "1.0", "representation") | 96 | >>> test_cache.set("Don't cache this.", json, "1.0", "representation") |
105 | 97 | >>> test_dict.keys() | 97 | >>> for key in test_dict: |
106 | 98 | ['Cache this.,application/json,1.0'] | 98 | ... print(key) |
107 | 99 | Cache this.,application/json,1.0 | ||
108 | 99 | 100 | ||
109 | 100 | ...UNLESS the representation being cached is for the version "cache | 101 | ...UNLESS the representation being cached is for the version "cache |
110 | 101 | everything!" | 102 | everything!" |
111 | @@ -206,7 +207,7 @@ | |||
112 | 206 | >>> cookbook = [cookbook for cookbook in COOKBOOKS | 207 | >>> cookbook = [cookbook for cookbook in COOKBOOKS |
113 | 207 | ... if cookbook.name == "Everyday Greens"][0] | 208 | ... if cookbook.name == "Everyday Greens"][0] |
114 | 208 | >>> cache.set(cookbook, json, 'devel', "Dummy value.") | 209 | >>> cache.set(cookbook, json, 'devel', "Dummy value.") |
116 | 209 | >>> print(dictionary.keys()[0]) | 210 | >>> print(list(dictionary.keys())[0]) |
117 | 210 | http://.../devel/cookbooks/Everyday%20Greens,application/json | 211 | http://.../devel/cookbooks/Everyday%20Greens,application/json |
118 | 211 | 212 | ||
119 | 212 | >>> from six.moves.urllib.parse import quote | 213 | >>> from six.moves.urllib.parse import quote |
120 | @@ -239,7 +240,7 @@ | |||
121 | 239 | 240 | ||
122 | 240 | >>> print(cache.get(recipe, json, 'devel')) | 241 | >>> print(cache.get(recipe, json, 'devel')) |
123 | 241 | None | 242 | None |
125 | 242 | >>> dictionary.keys() | 243 | >>> list(dictionary) |
126 | 243 | [] | 244 | [] |
127 | 244 | 245 | ||
128 | 245 | Data visibility | 246 | Data visibility |
129 | @@ -254,7 +255,7 @@ | |||
130 | 254 | >>> print(greens['confirmed']) | 255 | >>> print(greens['confirmed']) |
131 | 255 | tag:launchpad.net:2008:redacted | 256 | tag:launchpad.net:2008:redacted |
132 | 256 | 257 | ||
134 | 257 | >>> dictionary.keys() | 258 | >>> list(dictionary) |
135 | 258 | [] | 259 | [] |
136 | 259 | 260 | ||
137 | 260 | This means that if your entry resources typically contain data that's | 261 | This means that if your entry resources typically contain data that's |
138 | 261 | 262 | ||
139 | === modified file 'src/lazr/restful/metazcml.py' | |||
140 | --- src/lazr/restful/metazcml.py 2020-02-04 19:02:02 +0000 | |||
141 | +++ src/lazr/restful/metazcml.py 2020-07-22 23:32:54 +0000 | |||
142 | @@ -479,7 +479,7 @@ | |||
143 | 479 | registered_adapters = set() | 479 | registered_adapters = set() |
144 | 480 | block_mutator_operations = set() | 480 | block_mutator_operations = set() |
145 | 481 | 481 | ||
147 | 482 | methods = interface.namesAndDescriptions(True) | 482 | methods = list(interface.namesAndDescriptions(True)) |
148 | 483 | for iface in REGISTERED_CONTRIBUTORS[interface]: | 483 | for iface in REGISTERED_CONTRIBUTORS[interface]: |
149 | 484 | methods.extend(iface.namesAndDescriptions(True)) | 484 | methods.extend(iface.namesAndDescriptions(True)) |
150 | 485 | 485 | ||
151 | 486 | 486 | ||
152 | === modified file 'src/lazr/restful/simple.py' | |||
153 | --- src/lazr/restful/simple.py 2020-02-04 13:17:32 +0000 | |||
154 | +++ src/lazr/restful/simple.py 2020-07-22 23:32:54 +0000 | |||
155 | @@ -207,7 +207,7 @@ | |||
156 | 207 | 207 | ||
157 | 208 | @property | 208 | @property |
158 | 209 | def top_level_names(self): | 209 | def top_level_names(self): |
160 | 210 | return self.top_level_objects.keys() | 210 | return list(self.top_level_objects.keys()) |
161 | 211 | 211 | ||
162 | 212 | def get(self, request, name): | 212 | def get(self, request, name): |
163 | 213 | """Traverse to a top-level object.""" | 213 | """Traverse to a top-level object.""" |
164 | 214 | 214 | ||
165 | === modified file 'src/lazr/restful/tales.py' | |||
166 | --- src/lazr/restful/tales.py 2020-02-05 12:16:44 +0000 | |||
167 | +++ src/lazr/restful/tales.py 2020-07-22 23:32:54 +0000 | |||
168 | @@ -222,7 +222,7 @@ | |||
169 | 222 | # iterate through attributes one at a time because some | 222 | # iterate through attributes one at a time because some |
170 | 223 | # versions of docutils don't case-normalize attributes. | 223 | # versions of docutils don't case-normalize attributes. |
171 | 224 | for attr_dict in attr_dicts: | 224 | for attr_dict in attr_dicts: |
173 | 225 | for (key, val) in attr_dict.items(): | 225 | for (key, val) in list(attr_dict.items()): |
174 | 226 | # Prefix all CSS classes with "rst-"; and prefix all | 226 | # Prefix all CSS classes with "rst-"; and prefix all |
175 | 227 | # names with "rst-" to avoid conflicts. | 227 | # names with "rst-" to avoid conflicts. |
176 | 228 | if key.lower() in ('class', 'id', 'name'): | 228 | if key.lower() in ('class', 'id', 'name'): |
177 | 229 | 229 | ||
178 | === modified file 'src/lazr/restful/tests/test_declarations.py' | |||
179 | --- src/lazr/restful/tests/test_declarations.py 2020-02-19 16:09:10 +0000 | |||
180 | +++ src/lazr/restful/tests/test_declarations.py 2020-07-22 23:32:54 +0000 | |||
181 | @@ -948,8 +948,8 @@ | |||
182 | 948 | *self.utility.active_versions) | 948 | *self.utility.active_versions) |
183 | 949 | interface_10 = interfaces[0].object | 949 | interface_10 = interfaces[0].object |
184 | 950 | interface_20 = interfaces[1].object | 950 | interface_20 = interfaces[1].object |
187 | 951 | self.assertEqual(interface_10.names(), ['field']) | 951 | self.assertEqual(list(interface_10.names()), ['field']) |
188 | 952 | self.assertEqual(interface_20.names(), ['field']) | 952 | self.assertEqual(list(interface_20.names()), ['field']) |
189 | 953 | 953 | ||
190 | 954 | def test_field_exported_as_of_later_version_is_not_exported_in_earlier_versions(self): | 954 | def test_field_exported_as_of_later_version_is_not_exported_in_earlier_versions(self): |
191 | 955 | # If you export a field as_of version 2.0, it's not present in | 955 | # If you export a field as_of version 2.0, it's not present in |
192 | @@ -959,8 +959,8 @@ | |||
193 | 959 | *self.utility.active_versions) | 959 | *self.utility.active_versions) |
194 | 960 | interface_10 = interfaces[0].object | 960 | interface_10 = interfaces[0].object |
195 | 961 | interface_20 = interfaces[1].object | 961 | interface_20 = interfaces[1].object |
198 | 962 | self.assertEqual(interface_10.names(), []) | 962 | self.assertEqual(list(interface_10.names()), []) |
199 | 963 | self.assertEqual(interface_20.names(), ['field']) | 963 | self.assertEqual(list(interface_20.names()), ['field']) |
200 | 964 | 964 | ||
201 | 965 | def test_field_not_exported_using_as_of_fails(self): | 965 | def test_field_not_exported_using_as_of_fails(self): |
202 | 966 | # If you export a field without specifying as_of, you get an | 966 | # If you export a field without specifying as_of, you get an |