File tree Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -59,12 +59,8 @@ struct enum_type_caster {
5959 base_caster base;
6060 if (base.load (src, convert)) {
6161 T v = static_cast <T>(base);
62- if (::google::protobuf::GetEnumDescriptor<EnumType>()->FindValueByNumber (v) ==
63- nullptr ) {
64- throw pybind11::value_error (" Invalid value " + std::to_string (v) +
65- " for ::google::protobuf::Enum " +
66- pybind11::type_id<EnumType>());
67- }
62+ // Behavior change 2023-07-19: Previously we only accept integers that
63+ // are valid values of the enum.
6864 value = static_cast <EnumType>(v);
6965 return true ;
7066 }
Original file line number Diff line number Diff line change @@ -19,8 +19,7 @@ def test_enum(self):
1919 self .assertEqual (
2020 m .adjust_enum (test_pb2 .TestMessage .ONE ), test_pb2 .TestMessage .TWO )
2121 self .assertEqual (m .adjust_enum (m .ZERO ), m .ONE )
22- with self .assertRaises (ValueError ):
23- m .adjust_enum (7 )
22+ self .assertEqual (m .adjust_enum (7 ), m .ZERO )
2423 with self .assertRaises (TypeError ):
2524 m .adjust_enum ('ZERO' )
2625
You can’t perform that action at this time.
0 commit comments