aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google/protobuf/symbol_database.py
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2015-12-11 17:09:20 -0800
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2015-12-11 17:10:28 -0800
commite841bac4fcf47f809e089a70d5f84ac37b3883df (patch)
treed25dc5fc814db182c04c5f276ff1a609c5965a5a /python/google/protobuf/symbol_database.py
parent99a6a95c751a28a3cc33dd2384959179f83f682c (diff)
Down-integrate from internal code base.
Diffstat (limited to 'python/google/protobuf/symbol_database.py')
-rw-r--r--python/google/protobuf/symbol_database.py32
1 files changed, 3 insertions, 29 deletions
diff --git a/python/google/protobuf/symbol_database.py b/python/google/protobuf/symbol_database.py
index b81ef4d7..87760f26 100644
--- a/python/google/protobuf/symbol_database.py
+++ b/python/google/protobuf/symbol_database.py
@@ -60,7 +60,6 @@ Example usage:
"""
-from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool
@@ -73,37 +72,12 @@ class SymbolDatabase(object):
buffer types used within a program.
"""
- # pylint: disable=protected-access
- if _descriptor._USE_C_DESCRIPTORS:
-
- def __new__(cls):
- raise TypeError("Instances of SymbolDatabase cannot be created")
-
- @classmethod
- def _CreateDefaultDatabase(cls):
- self = object.__new__(cls) # Bypass the __new__ above.
- # Don't call __init__() and initialize here.
- self._symbols = {}
- self._symbols_by_file = {}
- # As of today all descriptors are registered and retrieved from
- # _message.default_pool (see FileDescriptor.__new__), so it's not
- # necessary to use another pool.
- self.pool = _descriptor._message.default_pool
- return self
- # pylint: enable=protected-access
-
- else:
-
- @classmethod
- def _CreateDefaultDatabase(cls):
- return cls()
-
- def __init__(self):
+ def __init__(self, pool=None):
"""Constructor."""
self._symbols = {}
self._symbols_by_file = {}
- self.pool = descriptor_pool.DescriptorPool()
+ self.pool = pool or descriptor_pool.Default()
def RegisterMessage(self, message):
"""Registers the given message type in the local database.
@@ -203,7 +177,7 @@ class SymbolDatabase(object):
result.update(self._symbols_by_file[f])
return result
-_DEFAULT = SymbolDatabase._CreateDefaultDatabase()
+_DEFAULT = SymbolDatabase(pool=descriptor_pool.Default())
def Default():