mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 06:35:12 +00:00
chore: add err guard to capsule destructor and add a move to iostream (#3958)
* Add err guard to capsule destructor * only uses ostream currently * can these be noexcept * Add back header * fix for older compilers * This should at least be noexcept * Add missing move * Apparently not noexcept for old llvm
This commit is contained in:
parent
8d14e666e3
commit
68f8010500
@ -100,7 +100,7 @@ private:
|
||||
|
||||
if (size > remainder) {
|
||||
str line(pbase(), size - remainder);
|
||||
pywrite(line);
|
||||
pywrite(std::move(line));
|
||||
pyflush();
|
||||
}
|
||||
|
||||
|
@ -1581,6 +1581,8 @@ public:
|
||||
|
||||
capsule(const void *value, void (*destructor)(void *)) {
|
||||
m_ptr = PyCapsule_New(const_cast<void *>(value), nullptr, [](PyObject *o) {
|
||||
// guard if destructor called while err indicator is set
|
||||
error_scope error_guard;
|
||||
auto destructor = reinterpret_cast<void (*)(void *)>(PyCapsule_GetContext(o));
|
||||
if (destructor == nullptr) {
|
||||
if (PyErr_Occurred()) {
|
||||
|
Loading…
Reference in New Issue
Block a user