The example in the pybind11 documentation was wrong, see https://github.com/pybind/pybind11/pull/1103