Skip to content

Commit

Permalink
Internal change only
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 491993057
  • Loading branch information
anandolee authored and copybara-github committed Nov 30, 2022
1 parent 85debe8 commit 3d3bebf
Show file tree
Hide file tree
Showing 41 changed files with 143 additions and 136 deletions.
Empty file modified python/google/protobuf/descriptor.py
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions python/google/protobuf/internal/api_implementation.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def _CanImport(mod_name):
try:
# pylint: disable=g-import-not-at-top
from google.protobuf.pyext import _message
sys.modules['google.protobuf.internal.cpp._message'] = _message
_c_module = _message
del _message
except ImportError:
Expand Down Expand Up @@ -151,6 +152,12 @@ def Type():
return _implementation_type


def _SetType(implementation_type):
"""Never use! Only for protobuf benchmark."""
global _implementation_type
_implementation_type = implementation_type


# See comment on 'Type' above.
# TODO(jieluo): Remove the API, it returns a constant. b/228102101
def Version():
Expand Down
Empty file modified python/google/protobuf/internal/containers.py
100644 → 100755
Empty file.
Empty file modified python/google/protobuf/internal/decoder.py
100644 → 100755
Empty file.
Empty file modified python/google/protobuf/internal/encoder.py
100644 → 100755
Empty file.
Empty file modified python/google/protobuf/internal/python_message.py
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion python/google/protobuf/internal/python_protobuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Author: qrczak@google.com (Marcin Kowalczyk)

#include "google/protobuf/python/python_protobuf.h"
#include "third_party/py/google/protobuf/python_protobuf.h"

namespace google {
namespace protobuf {
Expand Down
7 changes: 3 additions & 4 deletions python/google/protobuf/internal/test_util.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@
long = int # Python 3


# Tests whether the given TestAllTypes message is
# protobuf_unittest.TestAllTypes or not.
# Tests whether the given TestAllTypes message is proto2 or not.
# This is used to gate several fields/features that only exist
# for the protobuf_unittest version of the message.
# for the proto2 version of the message.
def IsProto2(message):
return message.DESCRIPTOR.full_name == 'protobuf_unittest.TestAllTypes'
return message.DESCRIPTOR.syntax == "proto2"


def SetAllNonLazyFields(message):
Expand Down
Empty file modified python/google/protobuf/internal/type_checkers.py
100644 → 100755
Empty file.
Empty file modified python/google/protobuf/message.py
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions python/google/protobuf/proto_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
// Then use the methods of the returned class:
// py_proto_api->GetMessagePointer(...);

#ifndef GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__
#define GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__

#define PY_SSIZE_T_CLEAN
#include <Python.h>
Expand Down Expand Up @@ -141,4 +141,4 @@ inline const char* PyProtoAPICapsuleName() {
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_PROTO_API_H__
12 changes: 6 additions & 6 deletions python/google/protobuf/pyext/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Author: petar@google.com (Petar Petrov)

#include "google/protobuf/pyext/descriptor.h"
#include "third_party/py/google/protobuf/pyext/descriptor.h"

#define PY_SSIZE_T_CLEAN
#include <Python.h>
Expand All @@ -42,11 +42,11 @@

#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/dynamic_message.h"
#include "google/protobuf/pyext/descriptor_containers.h"
#include "google/protobuf/pyext/descriptor_pool.h"
#include "google/protobuf/pyext/message.h"
#include "google/protobuf/pyext/message_factory.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "third_party/py/google/protobuf/pyext/descriptor_containers.h"
#include "third_party/py/google/protobuf/pyext/descriptor_pool.h"
#include "third_party/py/google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/message_factory.h"
#include "third_party/py/google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"

Expand Down
6 changes: 3 additions & 3 deletions python/google/protobuf/pyext/descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

// Author: petar@google.com (Petar Petrov)

#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__

#define PY_SSIZE_T_CLEAN
#include <Python.h>
Expand Down Expand Up @@ -102,4 +102,4 @@ bool InitDescriptor();
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
8 changes: 4 additions & 4 deletions python/google/protobuf/pyext/descriptor_containers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@

#include <string>

#include "google/protobuf/pyext/descriptor_containers.h"
#include "third_party/py/google/protobuf/pyext/descriptor_containers.h"
// clang-format on

#include "google/protobuf/descriptor.h"
#include "google/protobuf/pyext/descriptor.h"
#include "google/protobuf/pyext/descriptor_pool.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "third_party/py/google/protobuf/pyext/descriptor.h"
#include "third_party/py/google/protobuf/pyext/descriptor_pool.h"
#include "third_party/py/google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "absl/strings/string_view.h"

#define PyString_AsStringAndSize(ob, charpp, sizep) \
Expand Down
6 changes: 3 additions & 3 deletions python/google/protobuf/pyext/descriptor_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__

// Mappings and Sequences of descriptors.
// They implement containers like fields_by_name, EnumDescriptor.values...
Expand Down Expand Up @@ -107,4 +107,4 @@ PyObject* NewServiceMethodsByName(const ServiceDescriptor* descriptor);
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__
6 changes: 3 additions & 3 deletions python/google/protobuf/pyext/descriptor_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// This file defines a C++ DescriptorDatabase, which wraps a Python Database
// and delegate all its operations to Python methods.

#include "google/protobuf/pyext/descriptor_database.h"
#include "third_party/py/google/protobuf/pyext/descriptor_database.h"

#include <cstdint>
#include <string>
Expand All @@ -40,8 +40,8 @@
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/pyext/message.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "third_party/py/google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/scoped_pyobject_ptr.h"

namespace google {
namespace protobuf {
Expand Down
6 changes: 3 additions & 3 deletions python/google/protobuf/pyext/descriptor_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__

#define PY_SSIZE_T_CLEAN
#include <Python.h>
Expand Down Expand Up @@ -83,4 +83,4 @@ class PyDescriptorDatabase : public DescriptorDatabase {
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_DATABASE_H__
13 changes: 7 additions & 6 deletions python/google/protobuf/pyext/descriptor_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
#include <Python.h>

#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/pyext/descriptor.h"
#include "google/protobuf/pyext/descriptor_database.h"
#include "google/protobuf/pyext/descriptor_pool.h"
#include "google/protobuf/pyext/message.h"
#include "google/protobuf/pyext/message_factory.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "third_party/py/google/protobuf/pyext/descriptor.h"
#include "third_party/py/google/protobuf/pyext/descriptor_database.h"
#include "third_party/py/google/protobuf/pyext/descriptor_pool.h"
#include "third_party/py/google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/message_factory.h"
#include "third_party/py/google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "absl/strings/string_view.h"
#include "absl/strings/str_replace.h"

#define PyString_AsStringAndSize(ob, charpp, sizep) \
(PyUnicode_Check(ob) \
Expand Down
6 changes: 3 additions & 3 deletions python/google/protobuf/pyext/descriptor_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__

#define PY_SSIZE_T_CLEAN
#include <Python.h>
Expand Down Expand Up @@ -146,4 +146,4 @@ bool InitDescriptorPool();
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__
14 changes: 7 additions & 7 deletions python/google/protobuf/pyext/extension_dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// Author: anuraag@google.com (Anuraag Agrawal)
// Author: tibell@google.com (Johan Tibell)

#include "google/protobuf/pyext/extension_dict.h"
#include "third_party/py/google/protobuf/pyext/extension_dict.h"

#include <cstdint>
#include <memory>
Expand All @@ -43,12 +43,12 @@
#include "google/protobuf/descriptor.h"
#include "google/protobuf/dynamic_message.h"
#include "google/protobuf/message.h"
#include "google/protobuf/pyext/descriptor.h"
#include "google/protobuf/pyext/message.h"
#include "google/protobuf/pyext/message_factory.h"
#include "google/protobuf/pyext/repeated_composite_container.h"
#include "google/protobuf/pyext/repeated_scalar_container.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "third_party/py/google/protobuf/pyext/descriptor.h"
#include "third_party/py/google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/message_factory.h"
#include "third_party/py/google/protobuf/pyext/repeated_composite_container.h"
#include "third_party/py/google/protobuf/pyext/repeated_scalar_container.h"
#include "third_party/py/google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "absl/strings/string_view.h"

#define PyString_AsStringAndSize(ob, charpp, sizep) \
Expand Down
8 changes: 4 additions & 4 deletions python/google/protobuf/pyext/extension_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
// Author: anuraag@google.com (Anuraag Agrawal)
// Author: tibell@google.com (Johan Tibell)

#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__

#define PY_SSIZE_T_CLEAN
#include <Python.h>

#include "google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/message.h"

namespace google {
namespace protobuf {
Expand Down Expand Up @@ -67,4 +67,4 @@ ExtensionDict* NewExtensionDict(CMessage *parent);
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__
6 changes: 3 additions & 3 deletions python/google/protobuf/pyext/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "google/protobuf/pyext/field.h"
#include "third_party/py/google/protobuf/pyext/field.h"

#include "google/protobuf/descriptor.h"
#include "google/protobuf/pyext/descriptor.h"
#include "google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/descriptor.h"
#include "third_party/py/google/protobuf/pyext/message.h"

namespace google {
namespace protobuf {
Expand Down
6 changes: 3 additions & 3 deletions python/google/protobuf/pyext/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__

#define PY_SSIZE_T_CLEAN
#include <Python.h>
Expand Down Expand Up @@ -57,4 +57,4 @@ PyObject* NewFieldProperty(const FieldDescriptor* field_descriptor);
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_FIELD_H__
10 changes: 5 additions & 5 deletions python/google/protobuf/pyext/map_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Author: haberman@google.com (Josh Haberman)

#include "google/protobuf/pyext/map_container.h"
#include "third_party/py/google/protobuf/pyext/map_container.h"

#include <cstdint>
#include <memory>
Expand All @@ -41,10 +41,10 @@
#include "google/protobuf/map.h"
#include "google/protobuf/map_field.h"
#include "google/protobuf/message.h"
#include "google/protobuf/pyext/message.h"
#include "google/protobuf/pyext/message_factory.h"
#include "google/protobuf/pyext/repeated_composite_container.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "third_party/py/google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/message_factory.h"
#include "third_party/py/google/protobuf/pyext/repeated_composite_container.h"
#include "third_party/py/google/protobuf/pyext/scoped_pyobject_ptr.h"

namespace google {
namespace protobuf {
Expand Down
8 changes: 4 additions & 4 deletions python/google/protobuf/pyext/map_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__

#define PY_SSIZE_T_CLEAN
#include <Python.h>
Expand All @@ -38,7 +38,7 @@

#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"
#include "google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/message.h"

namespace google {
namespace protobuf {
Expand Down Expand Up @@ -86,4 +86,4 @@ extern MessageMapContainer* NewMessageMapContainer(
} // namespace protobuf
} // namespace google

#endif // GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_PYTHON_CPP_MAP_CONTAINER_H__
26 changes: 13 additions & 13 deletions python/google/protobuf/pyext/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// Author: anuraag@google.com (Anuraag Agrawal)
// Author: tibell@google.com (Johan Tibell)

#include "google/protobuf/pyext/message.h"
#include "third_party/py/google/protobuf/pyext/message.h"

#include <structmember.h> // A Python header file.

Expand All @@ -57,18 +57,18 @@
#include "google/protobuf/message.h"
#include "google/protobuf/text_format.h"
#include "google/protobuf/unknown_field_set.h"
#include "google/protobuf/pyext/descriptor.h"
#include "google/protobuf/pyext/descriptor_pool.h"
#include "google/protobuf/pyext/extension_dict.h"
#include "google/protobuf/pyext/field.h"
#include "google/protobuf/pyext/map_container.h"
#include "google/protobuf/pyext/message_factory.h"
#include "google/protobuf/pyext/repeated_composite_container.h"
#include "google/protobuf/pyext/repeated_scalar_container.h"
#include "google/protobuf/pyext/safe_numerics.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "google/protobuf/pyext/unknown_field_set.h"
#include "google/protobuf/pyext/unknown_fields.h"
#include "third_party/py/google/protobuf/pyext/descriptor.h"
#include "third_party/py/google/protobuf/pyext/descriptor_pool.h"
#include "third_party/py/google/protobuf/pyext/extension_dict.h"
#include "third_party/py/google/protobuf/pyext/field.h"
#include "third_party/py/google/protobuf/pyext/map_container.h"
#include "third_party/py/google/protobuf/pyext/message_factory.h"
#include "third_party/py/google/protobuf/pyext/repeated_composite_container.h"
#include "third_party/py/google/protobuf/pyext/repeated_scalar_container.h"
#include "third_party/py/google/protobuf/pyext/safe_numerics.h"
#include "third_party/py/google/protobuf/pyext/scoped_pyobject_ptr.h"
#include "third_party/py/google/protobuf/pyext/unknown_field_set.h"
#include "third_party/py/google/protobuf/pyext/unknown_fields.h"
#include "google/protobuf/util/message_differencer.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
Expand Down
Loading

0 comments on commit 3d3bebf

Please sign in to comment.