summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/_pickle.c.h
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-04-04 10:08:54 (GMT)
committerGitHub <noreply@github.com>2023-04-04 10:08:54 (GMT)
commitc00dcf0e381a090f7e905f887a98bbf63c88af5a (patch)
tree2ad93745bec78762b4559b4c28b63df0fd86514d /Modules/clinic/_pickle.c.h
parent810d365b5eb2cf3043957ca2971f6e7a7cd87d0d (diff)
downloadcpython-c00dcf0e381a090f7e905f887a98bbf63c88af5a.zip
cpython-c00dcf0e381a090f7e905f887a98bbf63c88af5a.tar.gz
cpython-c00dcf0e381a090f7e905f887a98bbf63c88af5a.tar.bz2
gh-103092: Isolate `_pickle` module (#102982)
Co-authored-by: Mohamed Koubaa <koubaa.m@gmail.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Modules/clinic/_pickle.c.h')
-rw-r--r--Modules/clinic/_pickle.c.h76
1 files changed, 65 insertions, 11 deletions
diff --git a/Modules/clinic/_pickle.c.h b/Modules/clinic/_pickle.c.h
index adb3abc..539acc3 100644
--- a/Modules/clinic/_pickle.c.h
+++ b/Modules/clinic/_pickle.c.h
@@ -38,7 +38,42 @@ PyDoc_STRVAR(_pickle_Pickler_dump__doc__,
"Write a pickled representation of the given object to the open file.");
#define _PICKLE_PICKLER_DUMP_METHODDEF \
- {"dump", (PyCFunction)_pickle_Pickler_dump, METH_O, _pickle_Pickler_dump__doc__},
+ {"dump", _PyCFunction_CAST(_pickle_Pickler_dump), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _pickle_Pickler_dump__doc__},
+
+static PyObject *
+_pickle_Pickler_dump_impl(PicklerObject *self, PyTypeObject *cls,
+ PyObject *obj);
+
+static PyObject *
+_pickle_Pickler_dump(PicklerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+ # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
+ #else
+ # define KWTUPLE NULL
+ #endif
+
+ static const char * const _keywords[] = {"", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "dump",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[1];
+ PyObject *obj;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ obj = args[0];
+ return_value = _pickle_Pickler_dump_impl(self, cls, obj);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(_pickle_Pickler___sizeof____doc__,
"__sizeof__($self, /)\n"
@@ -242,15 +277,19 @@ PyDoc_STRVAR(_pickle_Unpickler_load__doc__,
"specified therein.");
#define _PICKLE_UNPICKLER_LOAD_METHODDEF \
- {"load", (PyCFunction)_pickle_Unpickler_load, METH_NOARGS, _pickle_Unpickler_load__doc__},
+ {"load", _PyCFunction_CAST(_pickle_Unpickler_load), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _pickle_Unpickler_load__doc__},
static PyObject *
-_pickle_Unpickler_load_impl(UnpicklerObject *self);
+_pickle_Unpickler_load_impl(UnpicklerObject *self, PyTypeObject *cls);
static PyObject *
-_pickle_Unpickler_load(UnpicklerObject *self, PyObject *Py_UNUSED(ignored))
+_pickle_Unpickler_load(UnpicklerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- return _pickle_Unpickler_load_impl(self);
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "load() takes no arguments");
+ return NULL;
+ }
+ return _pickle_Unpickler_load_impl(self, cls);
}
PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__,
@@ -267,26 +306,41 @@ PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__,
"needed. Both arguments passed are str objects.");
#define _PICKLE_UNPICKLER_FIND_CLASS_METHODDEF \
- {"find_class", _PyCFunction_CAST(_pickle_Unpickler_find_class), METH_FASTCALL, _pickle_Unpickler_find_class__doc__},
+ {"find_class", _PyCFunction_CAST(_pickle_Unpickler_find_class), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _pickle_Unpickler_find_class__doc__},
static PyObject *
-_pickle_Unpickler_find_class_impl(UnpicklerObject *self,
+_pickle_Unpickler_find_class_impl(UnpicklerObject *self, PyTypeObject *cls,
PyObject *module_name,
PyObject *global_name);
static PyObject *
-_pickle_Unpickler_find_class(UnpicklerObject *self, PyObject *const *args, Py_ssize_t nargs)
+_pickle_Unpickler_find_class(UnpicklerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+ # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
+ #else
+ # define KWTUPLE NULL
+ #endif
+
+ static const char * const _keywords[] = {"", "", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "find_class",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[2];
PyObject *module_name;
PyObject *global_name;
- if (!_PyArg_CheckPositional("find_class", nargs, 2, 2)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
module_name = args[0];
global_name = args[1];
- return_value = _pickle_Unpickler_find_class_impl(self, module_name, global_name);
+ return_value = _pickle_Unpickler_find_class_impl(self, cls, module_name, global_name);
exit:
return return_value;
@@ -980,4 +1034,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=730dc26938561313 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a0e04b85e7bae626 input=a9049054013a1b77]*/