Skip to content

Commit

Permalink
Import MutableSequence from collections.abc on Python 3. (#6272)
Browse files Browse the repository at this point in the history
Fixes #5335.
  • Loading branch information
benjaminp authored and anandolee committed Nov 12, 2019
1 parent 9b0fa3e commit 9d61ead
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/google/protobuf/pyext/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2958,8 +2958,12 @@ bool InitProto2MessageModule(PyObject *m) {
reinterpret_cast<PyObject*>(
&RepeatedCompositeContainer_Type));

// Register them as collections.Sequence
// Register them as MutableSequence.
#if PY_MAJOR_VERSION >= 3
ScopedPyObjectPtr collections(PyImport_ImportModule("collections.abc"));
#else
ScopedPyObjectPtr collections(PyImport_ImportModule("collections"));
#endif
if (collections == NULL) {
return false;
}
Expand Down

0 comments on commit 9d61ead

Please sign in to comment.