diff options
author | Bo Yang <teboring@google.com> | 2016-09-23 21:13:11 +0000 |
---|---|---|
committer | Bo Yang <teboring@google.com> | 2016-09-23 21:38:35 +0000 |
commit | 411968d01f6ffe0d3483426d7c8197fd50783f97 (patch) | |
tree | bbd7920d267a8d4af4af61ef36edaba0dfa3dd0e /python/google | |
parent | 37c3d05f57b1d9165e5f31ce68e13cbb0920c853 (diff) | |
download | protobuf-411968d01f6ffe0d3483426d7c8197fd50783f97.tar.gz protobuf-411968d01f6ffe0d3483426d7c8197fd50783f97.tar.bz2 protobuf-411968d01f6ffe0d3483426d7c8197fd50783f97.zip |
Fix python cpp.
Diffstat (limited to 'python/google')
-rwxr-xr-x | python/google/protobuf/internal/python_message.py | 5 | ||||
-rw-r--r-- | python/google/protobuf/internal/testing_refleaks.py | 12 | ||||
-rw-r--r-- | python/google/protobuf/pyext/descriptor_pool.h | 2 | ||||
-rw-r--r-- | python/google/protobuf/pyext/message.cc | 7 |
4 files changed, 13 insertions, 13 deletions
diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py index 60b4baad..dc6565d4 100755 --- a/python/google/protobuf/internal/python_message.py +++ b/python/google/protobuf/internal/python_message.py @@ -63,7 +63,10 @@ except ImportError: # nothing like hermetic Python. This means lesser control on the system and # the six.moves package may be missing (is missing on 20150321 on gMac). Be # extra conservative and try to load the old replacement if it fails. - import copy_reg as copyreg + try: + import copy_reg as copyreg #PY26 + except ImportError: + import copyreg # We use "as" to avoid name collisions with variables. from google.protobuf.internal import containers diff --git a/python/google/protobuf/internal/testing_refleaks.py b/python/google/protobuf/internal/testing_refleaks.py index 51a9af9e..c461a9f4 100644 --- a/python/google/protobuf/internal/testing_refleaks.py +++ b/python/google/protobuf/internal/testing_refleaks.py @@ -38,11 +38,15 @@ If sys.gettotalrefcount() is not available (because Python was built without the Py_DEBUG option), then this module is a no-op and tests will run normally. """ -import copy_reg import gc import sys try: + import copy_reg as copyreg #PY26 +except ImportError: + import copyreg + +try: import unittest2 as unittest #PY26 except ImportError: import unittest @@ -74,7 +78,7 @@ class ReferenceLeakCheckerTestCase(unittest.TestCase): # python_message.py registers all Message classes to some pickle global # registry, which makes the classes immortal. # We save a copy of this registry, and reset it before we could references. - self._saved_pickle_registry = copy_reg.dispatch_table.copy() + self._saved_pickle_registry = copyreg.dispatch_table.copy() # Run the test twice, to warm up the instance attributes. super(ReferenceLeakCheckerTestCase, self).run(result=result) @@ -97,8 +101,8 @@ class ReferenceLeakCheckerTestCase(unittest.TestCase): result.addError(self, sys.exc_info()) def _getRefcounts(self): - copy_reg.dispatch_table.clear() - copy_reg.dispatch_table.update(self._saved_pickle_registry) + copyreg.dispatch_table.clear() + copyreg.dispatch_table.update(self._saved_pickle_registry) # It is sometimes necessary to gc.collect() multiple times, to ensure # that all objects can be collected. gc.collect() diff --git a/python/google/protobuf/pyext/descriptor_pool.h b/python/google/protobuf/pyext/descriptor_pool.h index 8de6c60b..c4d7d403 100644 --- a/python/google/protobuf/pyext/descriptor_pool.h +++ b/python/google/protobuf/pyext/descriptor_pool.h @@ -40,7 +40,7 @@ namespace google { namespace protobuf { namespace python { -class PyMessageFactory; +struct PyMessageFactory; // The (meta) type of all Messages classes. struct CMessageClass; diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 1b325469..7ff99aea 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -2831,13 +2831,6 @@ static Message* MutableCProtoInsidePyProtoImpl(PyObject* msg) { return cmsg->message; } -static const char module_docstring[] = -"python-proto2 is a module that can be used to enhance proto2 Python API\n" -"performance.\n" -"\n" -"It provides access to the protocol buffers C++ reflection API that\n" -"implements the basic protocol buffer functions."; - void InitGlobals() { // TODO(gps): Check all return values in this function for NULL and propagate // the error (MemoryError) on up to result in an import failure. These should |