Skip to content

Commit

Permalink
Breaking change: fix closed enum validation under editions
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruskal-google authored and copybara-github committed Dec 18, 2024
1 parent 556a426 commit 72b3eda
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 10 deletions.
5 changes: 0 additions & 5 deletions python/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,7 @@ static bool PyUpb_PyToUpbEnum(PyObject* obj, const upb_EnumDef* e,
} else {
int32_t i32;
if (!PyUpb_GetInt32(obj, &i32)) return false;
#ifdef UPB_FUTURE_PYTHON_CLOSED_ENUM_ENFORCEMENT
if (upb_EnumDef_IsClosed(e) && !upb_EnumDef_CheckNumber(e, i32)) {
#else
if (upb_FileDef_Syntax(upb_EnumDef_File(e)) == kUpb_Syntax_Proto2 &&
!upb_EnumDef_CheckNumber(e, i32)) {
#endif
PyErr_Format(PyExc_ValueError, "invalid enumerator %d", (int)i32);
return false;
}
Expand Down
4 changes: 0 additions & 4 deletions upb/port/def.inc
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,4 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
// user code can be updated before upgrading versions of protobuf.
#ifdef UPB_FUTURE_BREAKING_CHANGES

// Properly enforce closed enums in python.
// Owner: mkruskal@
#define UPB_FUTURE_PYTHON_CLOSED_ENUM_ENFORCEMENT 1

#endif
1 change: 0 additions & 1 deletion upb/port/undef.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@
#undef UPB_LINKARR_START
#undef UPB_LINKARR_STOP
#undef UPB_FUTURE_BREAKING_CHANGES
#undef UPB_FUTURE_PYTHON_CLOSED_ENUM_ENFORCEMENT

0 comments on commit 72b3eda

Please sign in to comment.