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

Method str

include/pybind11/pytypes.h:1827–1841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1825}
1826
1827inline str::str(const bytes &b) {
1828 char *buffer = nullptr;
1829 ssize_t length = 0;
1830 if (PyBytes_AsStringAndSize(b.ptr(), &buffer, &length) != 0) {
1831 throw error_already_set();
1832 }
1833 auto obj = reinterpret_steal<object>(PyUnicode_FromStringAndSize(buffer, length));
1834 if (!obj) {
1835 if (PyErr_Occurred()) {
1836 throw error_already_set();
1837 }
1838 pybind11_fail("Could not allocate string object!");
1839 }
1840 m_ptr = obj.release().ptr();
1841}
1842
1843/// \addtogroup pytypes
1844/// @{

Callers 6

valueMethod · 0.45
print_recarrayFunction · 0.45
get_utc_timestampFunction · 0.45
stl_bind.hFile · 0.45

Calls 4

strClass · 0.85
derivedClass · 0.85
ptrMethod · 0.80
releaseMethod · 0.80

Tested by 1

print_recarrayFunction · 0.36