pybind11/docs/advanced/cast
Tim Stumbaugh cca4c51ca4
Update errors in string "Explicit conversions" docs (#4658)
`PyUnicode_DecodeLatin1` requires you to pass in the `error`
parameter. The code as it is in the docs didn't compile.

There is a reference leak in the example
code. `PyUnicode_DecodeLatin1` returns a new reference. Calling
`py::str(PyObject*)` calls `PyObject_Str`, which also returns a new
reference. That reference is managed by the `py::str`
constructor (which correctly steals the reference, using the
`stolen_t` constructor), but the original reference returned by
`PyUnicode_DecodeLatin1` is never decref'd: it never makes it into an
`object`, and it's never manually decremented.

This fixes both of those issues. The code compiles, and I viewed the
sphinx docs locally.
2023-05-09 07:04:20 -07:00
..
chrono.rst Added ability to convert from datetime.date to system_clock::time_point (#1848) 2019-07-19 11:28:48 +02:00
custom.rst Open pybind11 namespace with consistent visility. (#4098) 2022-08-01 11:31:31 -07:00
eigen.rst Removed duplicated word in docs/advanced/cast/eigen.rst (#3458) 2021-11-12 10:53:43 -05:00
functional.rst Replace PYBIND11_PLUGIN with PYBIND11_MODULE 2017-05-29 03:21:19 +02:00
index.rst feat: py::type::of<T>() and py::type::of(h) (#2364) 2020-09-14 18:06:26 -04:00
overview.rst chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
stl.rst Open pybind11 namespace with consistent visility. (#4098) 2022-08-01 11:31:31 -07:00
strings.rst Update errors in string "Explicit conversions" docs (#4658) 2023-05-09 07:04:20 -07:00