Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix issues with collections.abc in Python 3.10+ #1188

Merged
merged 1 commit into from
May 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@
__author__ = 'petar@google.com (Petar Petrov)'

import collections

try:
packagerCor = collections.abc
except AttributeError:
packagerCor = collections

import sys


if sys.version_info[0] < 3:
# We would use collections.MutableMapping all the time, but in Python 2 it
# doesn't define __slots__. This causes two significant problems:
Expand Down Expand Up @@ -179,7 +186,7 @@ def setdefault(self, key, default=None):
else:
# In Python 3 we can just use MutableMapping directly, because it defines
# __slots__.
MutableMapping = collections.MutableMapping
MutableMapping = packagerCor.MutableMapping


class BaseContainer(object):
Expand Down Expand Up @@ -337,7 +344,7 @@ def __eq__(self, other):
# We are presumably comparing against some other sequence type.
return other == self._values

collections.MutableSequence.register(BaseContainer)
packagerCor.MutableSequence.register(BaseContainer)


class RepeatedCompositeFieldContainer(BaseContainer):
Expand Down