#include "Python.h"
#include "pycore_call.h"
#include "pycore_code.h"
#include "pycore_critical_section.h"
#include "pycore_hashtable.h"
#include "pycore_long.h"
#include "pycore_setobject.h"
#include "marshal.h"
#include "pycore_pystate.h"
#ifdef __APPLE__
# include "TargetConditionals.h"
#endif
#include "clinic/marshal.c.h"
#if defined(MS_WINDOWS)
#define MAX_MARSHAL_STACK_DEPTH …
#elif defined(__wasi__)
#define MAX_MARSHAL_STACK_DEPTH …
#elif defined(__APPLE__) && defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#define MAX_MARSHAL_STACK_DEPTH …
#else
#define MAX_MARSHAL_STACK_DEPTH …
#endif
#define TYPE_NULL …
#define TYPE_NONE …
#define TYPE_FALSE …
#define TYPE_TRUE …
#define TYPE_STOPITER …
#define TYPE_ELLIPSIS …
#define TYPE_BINARY_FLOAT …
#define TYPE_BINARY_COMPLEX …
#define TYPE_LONG …
#define TYPE_STRING …
#define TYPE_TUPLE …
#define TYPE_LIST …
#define TYPE_DICT …
#define TYPE_CODE …
#define TYPE_UNICODE …
#define TYPE_UNKNOWN …
#define TYPE_SET …
#define TYPE_FROZENSET …
#define TYPE_SLICE …
#define TYPE_INTERNED …
#define TYPE_ASCII …
#define TYPE_ASCII_INTERNED …
#define TYPE_SHORT_ASCII …
#define TYPE_SHORT_ASCII_INTERNED …
#define TYPE_INT …
#define TYPE_SMALL_TUPLE …
#define TYPE_COMPLEX …
#define TYPE_FLOAT …
#define TYPE_INT64 …
#define TYPE_REF …
#define FLAG_REF …
#define WFERR_OK …
#define WFERR_UNMARSHALLABLE …
#define WFERR_NESTEDTOODEEP …
#define WFERR_NOMEMORY …
#define WFERR_CODE_NOT_ALLOWED …
WFILE;
#define w_byte(c, p) …
static void
w_flush(WFILE *p)
{ … }
static int
w_reserve(WFILE *p, Py_ssize_t needed)
{ … }
static void
w_string(const void *s, Py_ssize_t n, WFILE *p)
{ … }
static void
w_short(int x, WFILE *p)
{ … }
static void
w_long(long x, WFILE *p)
{ … }
#define SIZE32_MAX …
#if SIZEOF_SIZE_T > 4
#define W_SIZE(n, p) …
#else
#define W_SIZE …
#endif
static void
w_pstring(const void *s, Py_ssize_t n, WFILE *p)
{ … }
static void
w_short_pstring(const void *s, Py_ssize_t n, WFILE *p)
{ … }
#define PyLong_MARSHAL_SHIFT …
#define PyLong_MARSHAL_BASE …
#define PyLong_MARSHAL_MASK …
#if PyLong_SHIFT % PyLong_MARSHAL_SHIFT != 0
#error "PyLong_SHIFT must be a multiple of PyLong_MARSHAL_SHIFT"
#endif
#define PyLong_MARSHAL_RATIO …
#define W_TYPE(t, p) …
static PyObject *
_PyMarshal_WriteObjectToString(PyObject *x, int version, int allow_code);
static void
w_PyLong(const PyLongObject *ob, char flag, WFILE *p)
{ … }
static void
w_float_bin(double v, WFILE *p)
{ … }
static void
w_float_str(double v, WFILE *p)
{ … }
static int
w_ref(PyObject *v, char *flag, WFILE *p)
{ … }
static void
w_complex_object(PyObject *v, char flag, WFILE *p);
static void
w_object(PyObject *v, WFILE *p)
{ … }
static void
w_complex_object(PyObject *v, char flag, WFILE *p)
{ … }
static void
w_decref_entry(void *key)
{ … }
static int
w_init_refs(WFILE *wf, int version)
{ … }
static void
w_clear_refs(WFILE *wf)
{ … }
void
PyMarshal_WriteLongToFile(long x, FILE *fp, int version)
{ … }
void
PyMarshal_WriteObjectToFile(PyObject *x, FILE *fp, int version)
{ … }
RFILE;
static const char *
r_string(Py_ssize_t n, RFILE *p)
{ … }
static int
r_byte(RFILE *p)
{ … }
static int
r_short(RFILE *p)
{ … }
static long
r_long(RFILE *p)
{ … }
static PyObject *
r_long64(RFILE *p)
{ … }
static PyObject *
r_PyLong(RFILE *p)
{ … }
static double
r_float_bin(RFILE *p)
{ … }
Py_NO_INLINE static double
r_float_str(RFILE *p)
{ … }
static Py_ssize_t
r_ref_reserve(int flag, RFILE *p)
{ … }
static PyObject *
r_ref_insert(PyObject *o, Py_ssize_t idx, int flag, RFILE *p)
{ … }
static PyObject *
r_ref(PyObject *o, int flag, RFILE *p)
{ … }
static PyObject *
r_object(RFILE *p)
{ … }
static PyObject *
read_object(RFILE *p)
{ … }
int
PyMarshal_ReadShortFromFile(FILE *fp)
{ … }
long
PyMarshal_ReadLongFromFile(FILE *fp)
{ … }
static off_t
getfilesize(FILE *fp)
{ … }
PyObject *
PyMarshal_ReadLastObjectFromFile(FILE *fp)
{ … }
PyObject *
PyMarshal_ReadObjectFromFile(FILE *fp)
{ … }
PyObject *
PyMarshal_ReadObjectFromString(const char *str, Py_ssize_t len)
{ … }
static PyObject *
_PyMarshal_WriteObjectToString(PyObject *x, int version, int allow_code)
{ … }
PyObject *
PyMarshal_WriteObjectToString(PyObject *x, int version)
{ … }
static PyObject *
marshal_dump_impl(PyObject *module, PyObject *value, PyObject *file,
int version, int allow_code)
{ … }
static PyObject *
marshal_load_impl(PyObject *module, PyObject *file, int allow_code)
{ … }
static PyObject *
marshal_dumps_impl(PyObject *module, PyObject *value, int version,
int allow_code)
{ … }
static PyObject *
marshal_loads_impl(PyObject *module, Py_buffer *bytes, int allow_code)
{ … }
static PyMethodDef marshal_methods[] = …;
PyDoc_STRVAR(module_doc,
"This module contains functions that can read and write Python values in\n\
a binary format. The format is specific to Python, but independent of\n\
machine architecture issues.\n\
\n\
Not all Python object types are supported; in general, only objects\n\
whose value is independent from a particular invocation of Python can be\n\
written and read by this module. The following types are supported:\n\
None, integers, floating-point numbers, strings, bytes, bytearrays,\n\
tuples, lists, sets, dictionaries, and code objects, where it\n\
should be understood that tuples, lists and dictionaries are only\n\
supported as long as the values contained therein are themselves\n\
supported; and recursive lists and dictionaries should not be written\n\
(they will cause infinite loops).\n\
\n\
Variables:\n\
\n\
version -- indicates the format that the module uses. Version 0 is the\n\
historical format, version 1 shares interned strings and version 2\n\
uses a binary format for floating-point numbers.\n\
Version 3 shares common object references (New in version 3.4).\n\
\n\
Functions:\n\
\n\
dump() -- write value to a file\n\
load() -- read value from a file\n\
dumps() -- marshal value as a bytes object\n\
loads() -- read value from a bytes-like object");
static int
marshal_module_exec(PyObject *mod)
{ … }
static PyModuleDef_Slot marshalmodule_slots[] = …;
static struct PyModuleDef marshalmodule = …;
PyMODINIT_FUNC
PyMarshal_Init(void)
{ … }