rust-cpython icon indicating copy to clipboard operation
rust-cpython copied to clipboard

ToPyObject example incorrect for PyString

Open stuhood opened this issue 5 years ago • 2 comments

ToPyObject indicates that:

You can always calls val.to_py_object(py).into_py_object() in order to obtain PyObject (the second into_py_object() call via the PythonObject trait corresponds to the upcast from PyList to PyObject).

But this doesn't seem to be the case for PyString, for which the ToPyObject impl targets itself, making the into_py_object call a noop.

stuhood avatar May 23 '20 19:05 stuhood

You should be able to use into_object() to convert a PyString to a PyObject. (into_py_object() just converts to the downcasted type, which is already PyString).

markbt avatar Jan 15 '21 20:01 markbt

(I'll update the docs later)

markbt avatar Jan 15 '21 20:01 markbt