Conversation
Signed-off-by: Nathan Rusch <nrusch@users.noreply.github.com>
nrusch
commented
Sep 19, 2026
Comment on lines
+481
to
+491
| #if defined(OIIO_PY_BACKEND_NANOBIND) | ||
| if (!py_str) { | ||
| py::raise_python_error(); | ||
| } | ||
| return py::steal<py::str>(py_str); | ||
| #else | ||
| if (!py_str) { | ||
| throw py::error_already_set(); | ||
| } | ||
| return py::reinterpret_steal<py::str>(py_str); | ||
| #endif |
Contributor
Author
There was a problem hiding this comment.
I went with a single function definition containing implementation details for both backends, but it would be easy enough to just have two definitions in the oiio_py namespace with the Python API call duplicated if you prefer. Or we could split the difference and alias the exception type and handle stealing functions in py_backend.h in order to collapse this into one code path.
nrusch
commented
Sep 19, 2026
| .OIIO_PY_PROP_RO("name", | ||
| [](const ParamValue& self) { | ||
| return oiio_py::str(self.name().string()); | ||
| return py_str_escaped(self.name().string()); |
Contributor
Author
There was a problem hiding this comment.
Flagging that I've also wrapped the ParamValue.name accessor, because there's nothing that normalizes/sanitizes attribute names in the C++ API.
Collaborator
|
Those wheel failures are unrelated. I just merged a fix that should take care of them. If you rebase on the current main, they should go away. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new
py_str_escapedhelper function to handle conversion of string-like C++ types topy:strwithout raising aUnicodeDecodeErrorfor non-UTF-8 input data.This function is a fairly simple wrapper that calls the
PyUnicode_DecodeUTF8with the'surrogateescape'error handling scheme (described at https://docs.python.org/3/library/codecs.html#error-handlers) and transfers ownership to the binding-specific object type.Fixes #3856
Tests
Only manual tests so far, but I plan to add some test cases to the harness.
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.