Commit 4993943
toolshed: handle anonymous struct renames in check_cython_abi.py
The name of an anonymous struct is an implementation detail, so it is
acceptable for the name to change between builds (e.g. from the old
anon_structXX / anon_unionXX scheme to the newer MODULE__anon_podXX
scheme that Cython now emits). This change makes the checker verify
that anonymous structs have the same *structure*, while tolerating name
changes, so spurious "Missing" / "Added" errors are no longer reported
for pure renames.
Three improvements:
1. `_format_base_type_name`: unwrap `CConstOrVolatileTypeNode` instead
of falling through to its class name. Const/volatile qualifiers do
not affect ABI layout, and the old behaviour stored the Python class
name literally ("CConstOrVolatileTypeNode*") in generated .abi.json
files, which caused field-type mismatches when comparing builds where
the qualifier was expressed differently.
2. `_build_anon_rename_map`: new iterative bottom-up pass that builds a
mapping from old-style anon names (expected) to new-style anon_pod
names (found) by matching field content. Leaf structs (no anon-type
fields) are matched first; each round normalises the remaining
candidates using already-known renames, allowing parent structs that
embed renamed children to match in subsequent rounds.
3. `_normalize_type`: uses `re.sub` with `\b` word-boundary anchors
instead of plain `str.replace`, so a shorter name like "anon_struct1"
cannot corrupt a longer one like "anon_struct12" if iteration order
happens to process the shorter key first.
`check_structs` is updated to look up each expected struct through the
rename map, normalise expected field types before comparing, and skip
the "Added" report for new-style names that are confirmed renames.
Note: baselines generated with the old tool (containing
"CConstOrVolatileTypeNode*" type strings) must be regenerated with the
fixed tool before the rename-matching logic can work correctly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 786d91a commit 4993943
1 file changed
Lines changed: 79 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
| |||
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
266 | 326 | | |
267 | 327 | | |
268 | 328 | | |
| |||
289 | 349 | | |
290 | 350 | | |
291 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
292 | 355 | | |
293 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
294 | 359 | | |
295 | 360 | | |
296 | 361 | | |
297 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
298 | 368 | | |
299 | 369 | | |
300 | 370 | | |
| |||
310 | 380 | | |
311 | 381 | | |
312 | 382 | | |
313 | | - | |
314 | | - | |
315 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
316 | 389 | | |
317 | 390 | | |
318 | | - | |
| 391 | + | |
319 | 392 | | |
320 | 393 | | |
321 | 394 | | |
| |||
0 commit comments