Skip to content

Commit

Permalink
Make green_init a more generic tp_init function; this should remove a…
Browse files Browse the repository at this point in the history
…ny assumption about binary compatible layouts.

Refs #422
  • Loading branch information
jamadden committed Sep 10, 2024
1 parent 6984c77 commit db5c781
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/greenlet/greenlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,13 @@ green_setrun(BorrowedGreenlet self, BorrowedObject nrun, void* c);
static int
green_setparent(BorrowedGreenlet self, BorrowedObject nparent, void* c);

// green_init is used in the tp_init slot. So it's important that
// it can be called directly from CPython. Thus, we don't use
// BorrowedGreenlet and BorrowedObject --- although in theory
// these should be binary layout compatible, that may not be
// guaranteed to be the case (32-bit linux ppc possibly).
static int
green_init(BorrowedGreenlet self, BorrowedObject args, BorrowedObject kwargs)
green_init(PyGreenlet* self, PyObject* args, PyObject* kwargs)
{
PyArgParseParam run;
PyArgParseParam nparent;
Expand Down Expand Up @@ -876,7 +881,7 @@ PyGreenlet_New(PyObject* run, PyGreenlet* parent)
kwargs.SetItem("parent", (PyObject*)parent);
}

Require(green_init(g, mod_globs->empty_tuple, kwargs));
Require(green_init(g.borrow(), mod_globs->empty_tuple, kwargs.borrow()));
}
catch (const PyErrOccurred&) {
return nullptr;
Expand Down

0 comments on commit db5c781

Please sign in to comment.