(doc: Any, json_options: JSONOptions)
| 581 | |
| 582 | |
| 583 | def _parse_canonical_binary(doc: Any, json_options: JSONOptions) -> Union[Binary, uuid.UUID]: |
| 584 | binary = doc["$binary"] |
| 585 | b64 = binary["base64"] |
| 586 | subtype = binary["subType"] |
| 587 | if not isinstance(b64, str): |
| 588 | raise TypeError(f"$binary base64 must be a string: {doc}") |
| 589 | if not isinstance(subtype, str) or len(subtype) > 2: |
| 590 | raise TypeError(f"$binary subType must be a string at most 2 characters: {doc}") |
| 591 | if len(binary) != 2: |
| 592 | raise TypeError(f'$binary must include only "base64" and "subType" components: {doc}') |
| 593 | |
| 594 | data = base64.b64decode(b64.encode()) |
| 595 | return _binary_or_uuid(data, int(subtype, 16), json_options) |
| 596 | |
| 597 | |
| 598 | def _parse_canonical_datetime( |
no test coverage detected