aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/clinic/marshal.c.h
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2024-03-05 10:40:59 +0100
committerGitHub <noreply@github.com>2024-03-05 12:40:59 +0300
commit1ac13c847b5358faba44dbb638a828e24369467b (patch)
tree07672b4dd3604ad3dee540a02c6494cb7d10dc3d /contrib/tools/python3/Python/clinic/marshal.c.h
parentffcca3e7f7958ddc6487b91d3df8c01054bd0638 (diff)
downloadydb-1ac13c847b5358faba44dbb638a828e24369467b.tar.gz
Library import 16 (#2433)
Co-authored-by: robot-piglet <robot-piglet@yandex-team.com> Co-authored-by: deshevoy <deshevoy@yandex-team.com> Co-authored-by: robot-contrib <robot-contrib@yandex-team.com> Co-authored-by: thegeorg <thegeorg@yandex-team.com> Co-authored-by: robot-ya-builder <robot-ya-builder@yandex-team.com> Co-authored-by: svidyuk <svidyuk@yandex-team.com> Co-authored-by: shadchin <shadchin@yandex-team.com> Co-authored-by: robot-ratatosk <robot-ratatosk@yandex-team.com> Co-authored-by: innokentii <innokentii@yandex-team.com> Co-authored-by: arkady-e1ppa <arkady-e1ppa@yandex-team.com> Co-authored-by: snermolaev <snermolaev@yandex-team.com> Co-authored-by: dimdim11 <dimdim11@yandex-team.com> Co-authored-by: kickbutt <kickbutt@yandex-team.com> Co-authored-by: abdullinsaid <abdullinsaid@yandex-team.com> Co-authored-by: korsunandrei <korsunandrei@yandex-team.com> Co-authored-by: petrk <petrk@yandex-team.com> Co-authored-by: miroslav2 <miroslav2@yandex-team.com> Co-authored-by: serjflint <serjflint@yandex-team.com> Co-authored-by: akhropov <akhropov@yandex-team.com> Co-authored-by: prettyboy <prettyboy@yandex-team.com> Co-authored-by: ilikepugs <ilikepugs@yandex-team.com> Co-authored-by: hiddenpath <hiddenpath@yandex-team.com> Co-authored-by: mikhnenko <mikhnenko@yandex-team.com> Co-authored-by: spreis <spreis@yandex-team.com> Co-authored-by: andreyshspb <andreyshspb@yandex-team.com> Co-authored-by: dimaandreev <dimaandreev@yandex-team.com> Co-authored-by: rashid <rashid@yandex-team.com> Co-authored-by: robot-ydb-importer <robot-ydb-importer@yandex-team.com> Co-authored-by: r-vetrov <r-vetrov@yandex-team.com> Co-authored-by: ypodlesov <ypodlesov@yandex-team.com> Co-authored-by: zaverden <zaverden@yandex-team.com> Co-authored-by: vpozdyayev <vpozdyayev@yandex-team.com> Co-authored-by: robot-cozmo <robot-cozmo@yandex-team.com> Co-authored-by: v-korovin <v-korovin@yandex-team.com> Co-authored-by: arikon <arikon@yandex-team.com> Co-authored-by: khoden <khoden@yandex-team.com> Co-authored-by: psydmm <psydmm@yandex-team.com> Co-authored-by: robot-javacom <robot-javacom@yandex-team.com> Co-authored-by: dtorilov <dtorilov@yandex-team.com> Co-authored-by: sennikovmv <sennikovmv@yandex-team.com> Co-authored-by: hcpp <hcpp@ydb.tech>
Diffstat (limited to 'contrib/tools/python3/Python/clinic/marshal.c.h')
-rw-r--r--contrib/tools/python3/Python/clinic/marshal.c.h164
1 files changed, 164 insertions, 0 deletions
diff --git a/contrib/tools/python3/Python/clinic/marshal.c.h b/contrib/tools/python3/Python/clinic/marshal.c.h
new file mode 100644
index 0000000000..a593b98054
--- /dev/null
+++ b/contrib/tools/python3/Python/clinic/marshal.c.h
@@ -0,0 +1,164 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+# include "pycore_gc.h" // PyGC_Head
+# include "pycore_runtime.h" // _Py_ID()
+#endif
+
+
+PyDoc_STRVAR(marshal_dump__doc__,
+"dump($module, value, file, version=version, /)\n"
+"--\n"
+"\n"
+"Write the value on the open file.\n"
+"\n"
+" value\n"
+" Must be a supported type.\n"
+" file\n"
+" Must be a writeable binary file.\n"
+" version\n"
+" Indicates the data format that dump should use.\n"
+"\n"
+"If the value has (or contains an object that has) an unsupported type, a\n"
+"ValueError exception is raised - but garbage data will also be written\n"
+"to the file. The object will not be properly read back by load().");
+
+#define MARSHAL_DUMP_METHODDEF \
+ {"dump", _PyCFunction_CAST(marshal_dump), METH_FASTCALL, marshal_dump__doc__},
+
+static PyObject *
+marshal_dump_impl(PyObject *module, PyObject *value, PyObject *file,
+ int version);
+
+static PyObject *
+marshal_dump(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *value;
+ PyObject *file;
+ int version = Py_MARSHAL_VERSION;
+
+ if (!_PyArg_CheckPositional("dump", nargs, 2, 3)) {
+ goto exit;
+ }
+ value = args[0];
+ file = args[1];
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ version = _PyLong_AsInt(args[2]);
+ if (version == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
+ return_value = marshal_dump_impl(module, value, file, version);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(marshal_load__doc__,
+"load($module, file, /)\n"
+"--\n"
+"\n"
+"Read one value from the open file and return it.\n"
+"\n"
+" file\n"
+" Must be readable binary file.\n"
+"\n"
+"If no valid value is read (e.g. because the data has a different Python\n"
+"version\'s incompatible marshal format), raise EOFError, ValueError or\n"
+"TypeError.\n"
+"\n"
+"Note: If an object containing an unsupported type was marshalled with\n"
+"dump(), load() will substitute None for the unmarshallable type.");
+
+#define MARSHAL_LOAD_METHODDEF \
+ {"load", (PyCFunction)marshal_load, METH_O, marshal_load__doc__},
+
+PyDoc_STRVAR(marshal_dumps__doc__,
+"dumps($module, value, version=version, /)\n"
+"--\n"
+"\n"
+"Return the bytes object that would be written to a file by dump(value, file).\n"
+"\n"
+" value\n"
+" Must be a supported type.\n"
+" version\n"
+" Indicates the data format that dumps should use.\n"
+"\n"
+"Raise a ValueError exception if value has (or contains an object that has) an\n"
+"unsupported type.");
+
+#define MARSHAL_DUMPS_METHODDEF \
+ {"dumps", _PyCFunction_CAST(marshal_dumps), METH_FASTCALL, marshal_dumps__doc__},
+
+static PyObject *
+marshal_dumps_impl(PyObject *module, PyObject *value, int version);
+
+static PyObject *
+marshal_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *value;
+ int version = Py_MARSHAL_VERSION;
+
+ if (!_PyArg_CheckPositional("dumps", nargs, 1, 2)) {
+ goto exit;
+ }
+ value = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ version = _PyLong_AsInt(args[1]);
+ if (version == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
+ return_value = marshal_dumps_impl(module, value, version);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(marshal_loads__doc__,
+"loads($module, bytes, /)\n"
+"--\n"
+"\n"
+"Convert the bytes-like object to a value.\n"
+"\n"
+"If no valid value is found, raise EOFError, ValueError or TypeError. Extra\n"
+"bytes in the input are ignored.");
+
+#define MARSHAL_LOADS_METHODDEF \
+ {"loads", (PyCFunction)marshal_loads, METH_O, marshal_loads__doc__},
+
+static PyObject *
+marshal_loads_impl(PyObject *module, Py_buffer *bytes);
+
+static PyObject *
+marshal_loads(PyObject *module, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ Py_buffer bytes = {NULL, NULL};
+
+ if (PyObject_GetBuffer(arg, &bytes, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&bytes, 'C')) {
+ _PyArg_BadArgument("loads", "argument", "contiguous buffer", arg);
+ goto exit;
+ }
+ return_value = marshal_loads_impl(module, &bytes);
+
+exit:
+ /* Cleanup for bytes */
+ if (bytes.obj) {
+ PyBuffer_Release(&bytes);
+ }
+
+ return return_value;
+}
+/*[clinic end generated code: output=12082d61d2942473 input=a9049054013a1b77]*/