Sets error using keys of 'dict1' and 'dict2'. 'dict1' and 'dict2' are assumed to be Python dictionaries.
| 619 | // Sets error using keys of 'dict1' and 'dict2'. |
| 620 | // 'dict1' and 'dict2' are assumed to be Python dictionaries. |
| 621 | void SetDifferentKeysError(PyObject* dict1, PyObject* dict2, string* error_msg, |
| 622 | bool* is_type_error) { |
| 623 | Safe_PyObjectPtr k1(MappingKeys(dict1)); |
| 624 | if (PyErr_Occurred() || k1.get() == nullptr) { |
| 625 | *error_msg = |
| 626 | ("The two dictionaries don't have the same set of keys. Failed to " |
| 627 | "fetch keys."); |
| 628 | return; |
| 629 | } |
| 630 | Safe_PyObjectPtr k2(MappingKeys(dict2)); |
| 631 | if (PyErr_Occurred() || k2.get() == nullptr) { |
| 632 | *error_msg = |
| 633 | ("The two dictionaries don't have the same set of keys. Failed to " |
| 634 | "fetch keys."); |
| 635 | return; |
| 636 | } |
| 637 | *is_type_error = false; |
| 638 | *error_msg = tensorflow::strings::StrCat( |
| 639 | "The two dictionaries don't have the same set of keys. " |
| 640 | "First structure has keys ", |
| 641 | PyObjectToString(k1.get()), ", while second structure has keys ", |
| 642 | PyObjectToString(k2.get())); |
| 643 | } |
| 644 | |
| 645 | // Returns true iff there were no "internal" errors. In other words, |
| 646 | // errors that has nothing to do with structure checking. |
no test coverage detected