Skip to content

Commit 1784361

Browse files
authored
Merge pull request #342 from python-greenlet/issue334
Attempt a fix for #334
2 parents ae570c5 + f891cc2 commit 1784361

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
was currently active. See `issue 332
1010
<https://github.com/python-greenlet/greenlet/issues/332>`_.
1111
- Various compilation and standards conformance fixes. See #335, #336,
12-
#300, #302.
12+
#300, #302, #334.
1313

1414

1515

src/greenlet/greenlet.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,9 @@ green_setparent(BorrowedGreenlet self, BorrowedObject nparent, void* UNUSED(cont
25062506
# define GREENLET_NO_CONTEXTVARS_REASON "This Python interpreter"
25072507
#endif
25082508

2509+
namespace greenlet
2510+
{
2511+
25092512
template<>
25102513
const OwnedObject
25112514
Greenlet::context<GREENLET_WHEN_PY37>(GREENLET_WHEN_PY37::Yes) const
@@ -2545,19 +2548,6 @@ Greenlet::context<GREENLET_WHEN_NOT_PY37>(GREENLET_WHEN_NOT_PY37::No) const
25452548
);
25462549
}
25472550

2548-
static PyObject*
2549-
green_getcontext(const PyGreenlet* self, void* UNUSED(context))
2550-
{
2551-
const Greenlet *const g = self->pimpl;
2552-
try {
2553-
OwnedObject result(g->context<G_IS_PY37>());
2554-
return result.relinquish_ownership();
2555-
}
2556-
catch(const PyErrOccurred&) {
2557-
return nullptr;
2558-
}
2559-
}
2560-
25612551
template<>
25622552
void Greenlet::context<GREENLET_WHEN_PY37>(BorrowedObject given, GREENLET_WHEN_PY37::Yes)
25632553
{
@@ -2602,6 +2592,21 @@ Greenlet::context<GREENLET_WHEN_NOT_PY37>(BorrowedObject UNUSED(given), GREENLET
26022592
);
26032593
}
26042594

2595+
};
2596+
2597+
static PyObject*
2598+
green_getcontext(const PyGreenlet* self, void* UNUSED(context))
2599+
{
2600+
const Greenlet *const g = self->pimpl;
2601+
try {
2602+
OwnedObject result(g->context<G_IS_PY37>());
2603+
return result.relinquish_ownership();
2604+
}
2605+
catch(const PyErrOccurred&) {
2606+
return nullptr;
2607+
}
2608+
}
2609+
26052610
static int
26062611
green_setcontext(BorrowedGreenlet self, PyObject* nctx, void* UNUSED(context))
26072612
{

0 commit comments

Comments
 (0)