Skip to content

Commit

Permalink
Merge pull request #342 from python-greenlet/issue334
Browse files Browse the repository at this point in the history
Attempt a fix for #334
  • Loading branch information
jamadden committed Jan 27, 2023
2 parents ae570c5 + f891cc2 commit 1784361
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
was currently active. See `issue 332
<https://github.com/python-greenlet/greenlet/issues/332>`_.
- Various compilation and standards conformance fixes. See #335, #336,
#300, #302.
#300, #302, #334.



Expand Down
31 changes: 18 additions & 13 deletions src/greenlet/greenlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,9 @@ green_setparent(BorrowedGreenlet self, BorrowedObject nparent, void* UNUSED(cont
# define GREENLET_NO_CONTEXTVARS_REASON "This Python interpreter"
#endif

namespace greenlet
{

template<>
const OwnedObject
Greenlet::context<GREENLET_WHEN_PY37>(GREENLET_WHEN_PY37::Yes) const
Expand Down Expand Up @@ -2545,19 +2548,6 @@ Greenlet::context<GREENLET_WHEN_NOT_PY37>(GREENLET_WHEN_NOT_PY37::No) const
);
}

static PyObject*
green_getcontext(const PyGreenlet* self, void* UNUSED(context))
{
const Greenlet *const g = self->pimpl;
try {
OwnedObject result(g->context<G_IS_PY37>());
return result.relinquish_ownership();
}
catch(const PyErrOccurred&) {
return nullptr;
}
}

template<>
void Greenlet::context<GREENLET_WHEN_PY37>(BorrowedObject given, GREENLET_WHEN_PY37::Yes)
{
Expand Down Expand Up @@ -2602,6 +2592,21 @@ Greenlet::context<GREENLET_WHEN_NOT_PY37>(BorrowedObject UNUSED(given), GREENLET
);
}

};

static PyObject*
green_getcontext(const PyGreenlet* self, void* UNUSED(context))
{
const Greenlet *const g = self->pimpl;
try {
OwnedObject result(g->context<G_IS_PY37>());
return result.relinquish_ownership();
}
catch(const PyErrOccurred&) {
return nullptr;
}
}

static int
green_setcontext(BorrowedGreenlet self, PyObject* nctx, void* UNUSED(context))
{
Expand Down

0 comments on commit 1784361

Please sign in to comment.