mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
internal change
PiperOrigin-RevId: 922907524
This commit is contained in:
parent
4576ba1c2f
commit
12baad3caa
11 changed files with 71 additions and 51 deletions
40
python/google/protobuf/breaking_changes.h
Normal file
40
python/google/protobuf/breaking_changes.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2024 Google LLC. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#ifndef THIRD_PARTY_PY_GOOGLE_PROTOBUF_BREAKING_CHANGES_H_
|
||||
#define THIRD_PARTY_PY_GOOGLE_PROTOBUF_BREAKING_CHANGES_H_
|
||||
|
||||
// Future versions of Protobuf Python will include breaking changes.
|
||||
// This file tracks Python-specific breaking changes that need to wait,
|
||||
// unlike upb-core breaking changes which can land immediately.
|
||||
|
||||
#ifdef PROTOBUF_PY_FUTURE_BREAKING_CHANGES
|
||||
|
||||
// Removes non-standard clamping behavior in RepeatedContainer.pop()
|
||||
// Owner: runze@
|
||||
#define PROTOBUF_PY_FUTURE_REMOVE_POP_CLAMP 1
|
||||
|
||||
// Fix PyProto C++ and upb implementations to return NotImplemented in
|
||||
// descriptor container equality checks for unrecognized types.
|
||||
// Owner: runze@
|
||||
#define PROTOBUF_PY_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED 1
|
||||
|
||||
// Make GetOptions() return immutable options.
|
||||
// Owner: runze@
|
||||
#define PROTOBUF_PY_FUTURE_FREEZE_OPTIONS 1
|
||||
|
||||
#else
|
||||
|
||||
#define PROTOBUF_PY_FUTURE_REMOVE_POP_CLAMP 0
|
||||
|
||||
#define PROTOBUF_PY_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED 0
|
||||
|
||||
#define PROTOBUF_PY_FUTURE_FREEZE_OPTIONS 0
|
||||
|
||||
#endif
|
||||
|
||||
#endif // THIRD_PARTY_PY_GOOGLE_PROTOBUF_BREAKING_CHANGES_H_
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
#include "absl/strings/string_view.h"
|
||||
#include "google/protobuf/descriptor.h"
|
||||
#include "google/protobuf/port_def.inc"
|
||||
#include "google/protobuf/breaking_changes.h"
|
||||
#include "google/protobuf/pyext/descriptor.h"
|
||||
#include "google/protobuf/pyext/descriptor_pool.h"
|
||||
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
|
||||
|
|
@ -346,7 +347,7 @@ static CompareResult DescriptorSequence_Equal(PyContainer* self,
|
|||
return CompareResult::kEqual;
|
||||
}
|
||||
|
||||
#if PROTOBUF_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED
|
||||
#if PROTOBUF_PY_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED
|
||||
// Any other object is not implemented.
|
||||
return CompareResult::kNotImplemented;
|
||||
#else
|
||||
|
|
@ -400,7 +401,7 @@ static CompareResult DescriptorMapping_Equal(PyContainer* self,
|
|||
return CompareResult::kEqual;
|
||||
}
|
||||
|
||||
#if PROTOBUF_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED
|
||||
#if PROTOBUF_PY_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED
|
||||
// Any other object is not implemented.
|
||||
return CompareResult::kNotImplemented;
|
||||
#else
|
||||
|
|
@ -424,7 +425,7 @@ static PyObject* RichCompare(PyContainer* self, PyObject* other, int opid) {
|
|||
}
|
||||
switch (result) {
|
||||
case CompareResult::kNotImplemented:
|
||||
#if PROTOBUF_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED
|
||||
#if PROTOBUF_PY_FUTURE_CONTAINER_EQ_RETURNS_NOTIMPLEMENTED
|
||||
Py_RETURN_NOTIMPLEMENTED;
|
||||
#else
|
||||
return nullptr; // Unreachable when this breaking change is disabled.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue