MCPcopy Create free account
hub / github.com/pybind/pybind11 / format_message_key_error_key_object

Function format_message_key_error_key_object

include/pybind11/stl_bind.h:697–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695};
696
697inline str format_message_key_error_key_object(handle py_key) {
698 str message = "pybind11::bind_map key";
699 if (!py_key) {
700 return message;
701 }
702 try {
703 message = str(py_key);
704 } catch (const std::exception &) {
705 try {
706 message = repr(py_key);
707 } catch (const std::exception &) {
708 return message;
709 }
710 }
711 const ssize_t cut_length = 100;
712 if (len(message) > 2 * cut_length + 3) {
713 return str(message[slice(0, cut_length, 1)]) + str("✄✄✄")
714 + str(message[slice(-cut_length, static_cast<ssize_t>(len(message)), 1)]);
715 }
716 return message;
717}
718
719template <typename KeyType>
720str format_message_key_error(const KeyType &key) {

Callers 1

format_message_key_errorFunction · 0.85

Calls 4

strClass · 0.85
reprFunction · 0.85
lenFunction · 0.85
sliceClass · 0.85

Tested by

no test coverage detected