Files
pybind11/include/pybind11
Yuanyuan Chen 5b379161aa Apply clang-tidy fixes to subinterpreter support code (#5929)
* Fix PyObject_HasAttrString return value

Signed-off-by: cyy <cyyever@outlook.com>

* Tidy unchecked files

Signed-off-by: cyy <cyyever@outlook.com>

* [skip ci] Handle PyObject_HasAttrString error when probing __notes__

PyObject_HasAttrString may return -1 to signal an error and set a
Python exception. The previous logic only checked for "!= 0", which
meant that the error path was treated the same as "attribute exists",
causing two problems: misreporting the presence of __notes__ and
leaving a spurious exception pending.

The earlier PR tightened the condition to "== 1" so that only a
successful lookup marks the error string as [WITH __notes__], but it
still left the -1 case unhandled. In the context of
error_fetch_and_normalize, we are already dealing with an active
exception and only want to best-effort detect whether normalization
attached any __notes__. If the attribute probe itself fails, we do not
want that secondary failure to affect later C-API calls or the error
we ultimately report.

This change stores the PyObject_HasAttrString return value, treats
"== 1" as "has __notes__", and explicitly calls PyErr_Clear() when
it returns -1. That way, we avoid leaking a secondary error while
still preserving the original exception information and hinting
[WITH __notes__] only when we can determine it reliably.

* Run clang-tidy with -DPYBIND11_HAS_SUBINTERPRETER_SUPPORT

* [skip ci] Revert "Run clang-tidy with -DPYBIND11_HAS_SUBINTERPRETER_SUPPORT"

This reverts commit bb6e751de4.

---------

Signed-off-by: cyy <cyyever@outlook.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
2025-12-13 16:20:26 -08:00
..
2025-08-30 23:07:03 -07:00
2025-05-16 21:58:43 -04:00
2025-11-13 16:29:02 -08:00