name_style_converter: Define __hash__() method
__hash__() isn't defined by default in Python 3 if __eq__() is user-defined. This fixes NameStyleConverter being unhashable in Python 3. The default __hash__() in Python 2 is defined in terms of id(self), i.e. identity-based hashing. However, since the custom __eq__() is defined in terms of value equality, this is probably unintended and a bug. Thus this CL also changes behaviour by defining __hash__() in terms of hash(self.original), i.e. value-based hashing. Traceback (most recent call last): File "../../third_party/blink/renderer/build/scripts/make_feature_policy_helper.py", line 80, in <module> json5_generator.Maker(FeaturePolicyFeatureWriter).main() File "C:\Google\chromium\src\third_party\blink\renderer\build\scripts\json5_generator.py", line 337, in main writer = self._writer_class(args.files, args.output_dir) File "../../third_party/blink/renderer/build/scripts/make_feature_policy_helper.py", line 44, in __init__ fp_origin_trial_dependency_map[feature['name']].append( TypeError: unhashable type: 'NameStyleConverter' Bug: 941669 Change-Id: Ie7811c7a5e0620376bf01c0d91a2c14043c85293 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093491 Commit-Queue: Raul Tambre <raul@tambre.ee> Reviewed-by:Kent Tamura <tkent@chromium.org> Auto-Submit: Raul Tambre <raul@tambre.ee> Cr-Commit-Position: refs/heads/master@{#748123}
Showing
Please register or sign in to comment