(data: Any, subtype: int, json_options: JSONOptions)
| 550 | |
| 551 | |
| 552 | def _binary_or_uuid(data: Any, subtype: int, json_options: JSONOptions) -> Union[Binary, uuid.UUID]: |
| 553 | # special handling for UUID |
| 554 | if subtype in ALL_UUID_SUBTYPES: |
| 555 | uuid_representation = json_options.uuid_representation |
| 556 | binary_value = Binary(data, subtype) |
| 557 | if uuid_representation == UuidRepresentation.UNSPECIFIED: |
| 558 | return binary_value |
| 559 | if subtype == UUID_SUBTYPE: |
| 560 | # Legacy behavior: use STANDARD with binary subtype 4. |
| 561 | uuid_representation = UuidRepresentation.STANDARD |
| 562 | elif uuid_representation == UuidRepresentation.STANDARD: |
| 563 | # subtype == OLD_UUID_SUBTYPE |
| 564 | # Legacy behavior: STANDARD is the same as PYTHON_LEGACY. |
| 565 | uuid_representation = UuidRepresentation.PYTHON_LEGACY |
| 566 | return binary_value.as_uuid(uuid_representation) |
| 567 | |
| 568 | if subtype == 0: |
| 569 | return cast(uuid.UUID, data) |
| 570 | return Binary(data, subtype) |
| 571 | |
| 572 | |
| 573 | def _parse_legacy_binary(doc: Any, json_options: JSONOptions) -> Union[Binary, uuid.UUID]: |
no test coverage detected