GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make __Pyx_CoroutineAwaitType non-pickleable (GH-4381) · 0dminnimda/cython@f94f26a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Cython/Utility
    • Coroutine.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Cython/Utility/Coroutine.c‎

Copy file name to clipboardExpand all lines: Cython/Utility/Coroutine.c
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,13 +1501,34 @@ static PyObject *__Pyx_CoroutineAwait_no_new(PyTypeObject *type, PyObject *args,
15011501
}
15021502
#endif
15031503

1504+
// In earlier versions of Python an object with no __dict__ and not __slots__ is assumed
1505+
// to be pickleable by default. Coroutine-wrappers have significant state so shouldn't be.
1506+
// Therefore provide a default implementation.
1507+
// Something similar applies to heaptypes (i.e. with type_specs) with protocols 0 and 1
1508+
// even in more recent versions.
1509+
// We are applying this to all Python versions (hence the commented out version guard)
1510+
// to make the behaviour explicit.
1511+
// #if PY_VERSION_HEX < 0x03060000 || CYTHON_USE_TYPE_SPECS
1512+
static PyObject *__Pyx_CoroutineAwait_reduce_ex(__pyx_CoroutineAwaitObject *self, PyObject *arg) {
1513+
CYTHON_UNUSED_VAR(arg);
1514+
PyErr_Format(PyExc_TypeError, "cannot pickle '%.200s' object",
1515+
Py_TYPE(self)->tp_name);
1516+
return NULL;
1517+
}
1518+
// #endif
1519+
15041520
static PyMethodDef __pyx_CoroutineAwait_methods[] = {
15051521
{"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O,
15061522
(char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next yielded value or raise StopIteration.")},
15071523
{"throw", (PyCFunction) __Pyx_CoroutineAwait_Throw, METH_VARARGS,
15081524
(char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next yielded value or raise StopIteration.")},
15091525
{"close", (PyCFunction) __Pyx_CoroutineAwait_Close, METH_NOARGS,
15101526
(char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
1527+
// only needed with type-specs or version<3.6, but included in all versions for clarity
1528+
// #if PY_VERSION_HEX < 0x03060000 || CYTHON_USE_TYPE_SPECS
1529+
{"__reduce_ex__", (PyCFunction) __Pyx_CoroutineAwait_reduce_ex, METH_O, 0},
1530+
{"__reduce__", (PyCFunction) __Pyx_CoroutineAwait_reduce_ex, METH_NOARGS, 0},
1531+
// #endif
15111532
{0, 0, 0, 0}
15121533
};
15131534

0 commit comments

Comments
0 (0)
You are visitor 01402605 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.