)]}'
{
  "commit": "b4939fcbfb9a90f02bea6bb70383eac418c8b3be",
  "tree": "202cbe9ea23c7480a80ffd8a10c664aeb88a062d",
  "parents": [
    "cd176ceeff94ec184abde945ef0867ebe9fb3664"
  ],
  "author": {
    "name": "Jason Rhinelander",
    "email": "jason@imaginary.ca",
    "time": "Fri Dec 03 13:20:32 2021 -0400"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Fri Dec 03 13:20:32 2021 -0400"
  },
  "message": "Expand std::string_view support to str, bytes, memoryview (#3521)\n\n* Expand string_view support to str, bytes, memoryview\r\n\r\n1. Allows constructing a str or bytes implicitly from a string_view;\r\n   this is essentially a small shortcut allowing a caller to write\r\n   `py::bytes{sv}` rather than `py::bytes{sv.data(), sv.size()}`.\r\n\r\n2. Allows implicit conversion *to* string_view from py::bytes -- this\r\n   saves a fair bit more as currently there is no simple way to get such\r\n   a view of the bytes without copying it (or resorting to Python API\r\n   calls).\r\n\r\n   (This is not done for `str` because when the str contains unicode we\r\n   have to allocate to a temporary and so there might not be some string\r\n   data we can properly view without owning.)\r\n\r\n3. Allows `memoryview::from_memory` to accept a string_view.  As with\r\n   the other from_memory calls, it\u0027s entirely your responsibility to\r\n   keep it alive.\r\n\r\nThis also required moving the string_view availability detection into\r\ndetail/common.h because this PR needs it in pytypes.h, which is higher\r\nup the include chain than cast.h where it was being detected currently.\r\n\r\n* Move string_view include to pytypes.h\r\n\r\n* CI-testing a fix for the \"ambiguous conversion\" issue.\r\n\r\nThis change is known to fix the `tensorflow::tstring` issue reported under https://github.com/pybind/pybind11/pull/3521#issuecomment-985100965\r\n\r\nTODO: Minimal reproducer for the `tensorflow::tstring` issue.\r\n\r\n* Make clang-tidy happy (hopefully).\r\n\r\n* Adding minimal reproducer for the `tensorflow::tstring` issue.\r\n\r\nError without the enable_if trick:\r\n\r\n```\r\n/usr/local/google/home/rwgk/forked/pybind11/tests/test_builtin_casters.cpp:169:16: error: ambiguous conversion for functional-style cast from \u0027TypeWithBothOperatorStringAndStringView\u0027 to \u0027py::bytes\u0027\r\n        return py::bytes(TypeWithBothOperatorStringAndStringView());\r\n               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../pytypes.h:1174:5: note: candidate constructor\r\n    bytes(const std::string \u0026s) : bytes(s.data(), s.size()) { }\r\n    ^\r\n/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../pytypes.h:1191:5: note: candidate constructor\r\n    bytes(std::string_view s) : bytes(s.data(), s.size()) { }\r\n    ^\r\n```\r\n\r\n* Adding missing NOLINTNEXTLINE\r\n\r\n* Also apply ambiguous conversion workaround to str()\r\n\r\nCo-authored-by: Ralf W. Grosse-Kunstleve \u003crwgk@google.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "097d41bdaf4417a105c2288347925d4c2aa0bc01",
      "old_mode": 33188,
      "old_path": "include/pybind11/cast.h",
      "new_id": "01dc5df73f3243792b1767311c01dea31538e673",
      "new_mode": 33188,
      "new_path": "include/pybind11/cast.h"
    },
    {
      "type": "modify",
      "old_id": "862451fd1321107855f65157e9eb0822c8869c4d",
      "old_mode": 33188,
      "old_path": "include/pybind11/detail/common.h",
      "new_id": "eb5fb08682db3704164d0db702836953064d13bc",
      "new_mode": 33188,
      "new_path": "include/pybind11/detail/common.h"
    },
    {
      "type": "modify",
      "old_id": "a08fd8ceb621d4c464ee4d1d45aa83038934a9c7",
      "old_mode": 33188,
      "old_path": "include/pybind11/pytypes.h",
      "new_id": "f803a05ca7f1a0837fb1dd19ce488638a54a7e05",
      "new_mode": 33188,
      "new_path": "include/pybind11/pytypes.h"
    },
    {
      "type": "modify",
      "old_id": "71c778e8e27cde6f48703dea462caca7a761925e",
      "old_mode": 33188,
      "old_path": "tests/test_builtin_casters.cpp",
      "new_id": "fe629e7c34559e066d76ceb7a7662382daf56439",
      "new_mode": 33188,
      "new_path": "tests/test_builtin_casters.cpp"
    },
    {
      "type": "modify",
      "old_id": "9c5e17a68eabb4f3bc3b183a5a83e5192e2303f4",
      "old_mode": 33188,
      "old_path": "tests/test_builtin_casters.py",
      "new_id": "b1f1e395a7e9cc6a55d96672619aa30492a90070",
      "new_mode": 33188,
      "new_path": "tests/test_builtin_casters.py"
    }
  ]
}
