Skip to content

Commit 72b3eda

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Breaking change: fix closed enum validation under editions
See https://protobuf.dev/news/2024-10-02/#python-setter-validation PiperOrigin-RevId: 707612946
1 parent 556a426 commit 72b3eda

File tree

3 files changed

+0
-10
lines changed

3 files changed

+0
-10
lines changed

python/convert.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,7 @@ static bool PyUpb_PyToUpbEnum(PyObject* obj, const upb_EnumDef* e,
180180
} else {
181181
int32_t i32;
182182
if (!PyUpb_GetInt32(obj, &i32)) return false;
183-
#ifdef UPB_FUTURE_PYTHON_CLOSED_ENUM_ENFORCEMENT
184183
if (upb_EnumDef_IsClosed(e) && !upb_EnumDef_CheckNumber(e, i32)) {
185-
#else
186-
if (upb_FileDef_Syntax(upb_EnumDef_File(e)) == kUpb_Syntax_Proto2 &&
187-
!upb_EnumDef_CheckNumber(e, i32)) {
188-
#endif
189184
PyErr_Format(PyExc_ValueError, "invalid enumerator %d", (int)i32);
190185
return false;
191186
}

upb/port/def.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,4 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
462462
// user code can be updated before upgrading versions of protobuf.
463463
#ifdef UPB_FUTURE_BREAKING_CHANGES
464464

465-
// Properly enforce closed enums in python.
466-
// Owner: mkruskal@
467-
#define UPB_FUTURE_PYTHON_CLOSED_ENUM_ENFORCEMENT 1
468-
469465
#endif

upb/port/undef.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,3 @@
6464
#undef UPB_LINKARR_START
6565
#undef UPB_LINKARR_STOP
6666
#undef UPB_FUTURE_BREAKING_CHANGES
67-
#undef UPB_FUTURE_PYTHON_CLOSED_ENUM_ENFORCEMENT

0 commit comments

Comments
 (0)