Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cpyrt/CPPConstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CPPConstructor : public CPPMethod {

protected:
bool InitExecutor_(Executor*&, CallContext* ctxt = nullptr) override;
bool ResultIsPyObject() const override { return false; }
};

// specialization for multiple inheritance disambiguation
Expand Down
3 changes: 2 additions & 1 deletion src/cpyrt/CPPMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ inline PyObject* cpyrt::CPPMethod::ExecuteFast(void* self, ptrdiff_t offset,
// Windows, so instead leaves the error be
#ifdef _WIN32
if (PyErr_Occurred()) {
Py_XDECREF(result);
if (ResultIsPyObject())
Py_XDECREF(result);
result = nullptr;
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/cpyrt/CPPMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class CPPMethod : public PyCallable {

virtual bool InitExecutor_(Executor*&, CallContext* ctxt = nullptr);

// whether fExecutor's result is a real PyObject* (ConstructorExecutor
// returns the new object's address instead)
virtual bool ResultIsPyObject() const { return true; }

private:
void Copy_(const CPPMethod&);
void Destroy_();
Expand Down
Loading