summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2023-01-27 17:24:53 -0600
committerGitHub <noreply@github.com>2023-01-27 17:24:53 -0600
commit1784361e97545c520384cfe50796136c337d1763 (patch)
tree362bcce18db130c337fffe3992022659f014994b
parentae570c56dbee9070b02eb2124f0b991cce52f4db (diff)
parentf891cc2d340e2f7983719d6f625ade517785933f (diff)
downloadgreenlet-1784361e97545c520384cfe50796136c337d1763.tar.gz
Merge pull request #342 from python-greenlet/issue334
Attempt a fix for #334
-rw-r--r--CHANGES.rst2
-rw-r--r--src/greenlet/greenlet.cpp31
2 files changed, 19 insertions, 14 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 75eaf15..12a1f50 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -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.
diff --git a/src/greenlet/greenlet.cpp b/src/greenlet/greenlet.cpp
index b761cab..1d6ddaa 100644
--- a/src/greenlet/greenlet.cpp
+++ b/src/greenlet/greenlet.cpp
@@ -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
@@ -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)
{
@@ -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))
{