(a, b)
| 430 | sentinel = object() # handle the possibility of a missing attribute/field |
| 431 | |
| 432 | def _compare(a, b): |
| 433 | # Compare two fields on an AST object, which may themselves be |
| 434 | # AST objects, lists of AST objects, or primitive ASDL types |
| 435 | # like identifiers and constants. |
| 436 | if isinstance(a, AST): |
| 437 | return compare( |
| 438 | a, |
| 439 | b, |
| 440 | compare_attributes=compare_attributes, |
| 441 | ) |
| 442 | elif isinstance(a, list): |
| 443 | # If a field is repeated, then both objects will represent |
| 444 | # the value as a list. |
| 445 | if len(a) != len(b): |
| 446 | return False |
| 447 | for a_item, b_item in zip(a, b): |
| 448 | if not _compare(a_item, b_item): |
| 449 | return False |
| 450 | else: |
| 451 | return True |
| 452 | else: |
| 453 | return type(a) is type(b) and a == b |
| 454 | |
| 455 | def _compare_fields(a, b): |
| 456 | if a._fields != b._fields: |
no test coverage detected
searching dependent graphs…