Commit 68f80105 by Aaron Gokaslan Committed by GitHub

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
parent 8d14e666
......@@ -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()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment