)]}'
{
  "commit": "c2d3e220bd1bfcf664e29d95ac2ed774fd6723f4",
  "tree": "cfe37d52b3cda6020d0d89d2736d1a4fadc632b2",
  "parents": [
    "d45a88105c3dab1dc2a1da831f1c83a0f3b57f8b"
  ],
  "author": {
    "name": "Ryan Cahoon",
    "email": "ryan.cahoon@zoox.com",
    "time": "Mon Oct 25 19:04:45 2021 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Oct 25 19:04:45 2021 -0700"
  },
  "message": "fix: the types for return_value_policy_override in optional_caster (#3376)\n\n* fix: the types for return_value_policy_override in optional_caster\r\n\r\n`return_value_policy_override` was not being applied correctly in\r\n`optional_caster` in two ways:\r\n- The `is_lvalue_reference` condition referenced `T`, which was the\r\n`optional\u003cT\u003e` type parameter from the class, when it should have used `T_`,\r\nwhich was the parameter to the `cast` function. `T_` can potentially be a\r\nreference type, but `T` will never be.\r\n- The type parameter passed to `return_value_policy_override` should be\r\n`T::value_type`, not `T`. This matches the way that the other STL container\r\ntype casters work.\r\n\r\nThe result of these issues was that a method/property definition which used a\r\n`reference` or `reference_internal` return value policy would create a Python\r\nvalue that\u0027s bound by reference to a temporary C++ object, resulting in\r\nundefined behavior. For reasons that I was not able to figure out fully, it\r\nseems like this causes problems when using old versions of `boost::optional`,\r\nbut not with recent versions of `boost::optional` or the `libstdc++`\r\nimplementation of `std::optional`. The issue (that the override to\r\n`return_value_policy::move` is never being applied) is present for all\r\nimplementations, it just seems like that somehow doesn\u0027t result in problems for\r\nthe some implementation of `optional`. This change includes a regression type\r\nwith a custom optional-like type which was able to reproduce the issue.\r\n\r\nPart of the issue with using the wrong types may have stemmed from the type\r\nvariables `T` and `T_` having very similar names. This also changes the type\r\nvariables in `optional_caster` to use slightly more descriptive names, which\r\nalso more closely follow the naming convention used by the other STL casters.\r\n\r\nFixes #3330\r\n\r\n* Fix clang-tidy complaints\r\n\r\n* Add missing NOLINT\r\n\r\n* Apply a couple more fixes\r\n\r\n* fix: support GCC 4.8\r\n\r\n* tests: avoid warning about unknown compiler for compilers missing C++17\r\n\r\n* Remove unneeded test module attribute\r\n\r\n* Change test enum to have more unique int values\r\n\r\nCo-authored-by: Aaron Gokaslan \u003cskylion.aaron@gmail.com\u003e\r\nCo-authored-by: Henry Schreiner \u003cHenrySchreinerIII@gmail.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2c017b4fef00085a78f5aad32d1ed9472b9825cd",
      "old_mode": 33188,
      "old_path": "include/pybind11/stl.h",
      "new_id": "3608d2989ceb0aa695cfac61f0988696f65cea94",
      "new_mode": 33188,
      "new_path": "include/pybind11/stl.h"
    },
    {
      "type": "modify",
      "old_id": "d4e7b71e1dd588b0636d6b8dda770e1e6b26f975",
      "old_mode": 33188,
      "old_path": "tests/CMakeLists.txt",
      "new_id": "e1b18dd74b458a5ba6c12ffac4cc0608d7913cef",
      "new_mode": 33188,
      "new_path": "tests/CMakeLists.txt"
    },
    {
      "type": "modify",
      "old_id": "7e3363c5ea56be769e7a6012c6f7a5d97476feb2",
      "old_mode": 33188,
      "old_path": "tests/test_stl.cpp",
      "new_id": "bc5c6553a27ef97c829514c0d65715b9d7f81929",
      "new_mode": 33188,
      "new_path": "tests/test_stl.cpp"
    },
    {
      "type": "modify",
      "old_id": "3f63d6c3a442136070054e83f728c4fed543606d",
      "old_mode": 33188,
      "old_path": "tests/test_stl.py",
      "new_id": "e217975944afdab009cd683eb65b52942bf9d205",
      "new_mode": 33188,
      "new_path": "tests/test_stl.py"
    }
  ]
}
