Commit c6c8a17
[numpy] Fix breakage in users of Python protobufs under NumPy 2.3rc1. (#22171)
As of NumPy 2.3.0rc1, numpy.bool scalars can no longer be interpreted as index values (https://github.com/numpy/numpy/releases/tag/v2.3.0rc1). This causes protobuf no longer to accept a np.bool scalar as a legal value for a boolean field.
We have two options:
a) either we can change protobuf so that it continues to accept NumPy boolean scalars (this change), or
b) decide that protobuf should reject NumPy boolean scalars and that users must update their code to cast to a Python bool explicitly.
I have no strong opinion as to which, but option (a) seems less disruptive.
No test updates are needed: the existing tests fail under NumPy 2.3.
PiperOrigin-RevId: 766629310
Co-authored-by: Peter Hawkins <phawkins@google.com>1 parent afede60 commit c6c8a17
File tree
3 files changed
+55
-7
lines changed- python
- google/protobuf
- internal
- pyext
3 files changed
+55
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
211 | 240 | | |
212 | 241 | | |
213 | 242 | | |
| |||
230 | 259 | | |
231 | 260 | | |
232 | 261 | | |
233 | | - | |
234 | | - | |
235 | | - | |
| 262 | + | |
236 | 263 | | |
237 | 264 | | |
238 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
118 | 126 | | |
119 | 127 | | |
120 | 128 | | |
121 | 129 | | |
| 130 | + | |
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
579 | | - | |
580 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
581 | 593 | | |
582 | 594 | | |
583 | 595 | | |
| |||
0 commit comments