google / google/apitools

class apitools.base.protorpclite.messages.Message is unhashable in Python 3

Open
#261 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
157
Forks
131
PR merge metrics
No merged PRs in 30d

Description

The class `apitools.base.protorpclite.messages.Message` is an unhashable type in Python 3 and as a result, raises a TypeError when used as a key in a dict.

The reason for this is that in Python 3.x "a class that overrides `__eq__()` and does not define `__hash__()` will have its `__hash__()` implicitly set to None" (https://docs.python.org/3.6/reference/datamodel.html#object.__hash__). This makes it unhashable.

In Python 2, since `__eq__()` was defined, it simply inherited the `__hash__()` from object. In Python 3 it doesn't.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.