aboutsummaryrefslogtreecommitdiff
path: root/python/google/protobuf/proto_builder.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/google/protobuf/proto_builder.py')
-rw-r--r--python/google/protobuf/proto_builder.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/python/google/protobuf/proto_builder.py b/python/google/protobuf/proto_builder.py
index 7489cf63..700e3c25 100644
--- a/python/google/protobuf/proto_builder.py
+++ b/python/google/protobuf/proto_builder.py
@@ -30,7 +30,10 @@
"""Dynamic Protobuf class creator."""
-import collections
+try:
+ from collections import OrderedDict
+except ImportError:
+ from ordereddict import OrderedDict #PY26
import hashlib
import os
@@ -80,7 +83,7 @@ def MakeSimpleProtoClass(fields, full_name, pool=None):
# an OrderedDict we keep the order, but otherwise we sort the field to ensure
# consistent ordering.
field_items = fields.items()
- if not isinstance(fields, collections.OrderedDict):
+ if not isinstance(fields, OrderedDict):
field_items = sorted(field_items)
# Use a consistent file name that is unlikely to conflict with any imported