@@ -549,7 +549,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p)
549549 w_object (co -> co_lnotab , p );
550550 }
551551 else if (PyObject_CheckBuffer (v )) {
552- /* Write unknown bytes-like objects as a byte string */
552+ /* Write unknown bytes-like objects as a bytes object */
553553 Py_buffer view ;
554554 if (PyObject_GetBuffer (v , & view , PyBUF_SIMPLE ) != 0 ) {
555555 w_byte (TYPE_UNKNOWN , p );
@@ -1086,7 +1086,7 @@ r_object(RFILE *p)
10861086 if (PyErr_Occurred ())
10871087 break ;
10881088 if (n < 0 || n > SIZE32_MAX ) {
1089- PyErr_SetString (PyExc_ValueError , "bad marshal data (string size out of range)" );
1089+ PyErr_SetString (PyExc_ValueError , "bad marshal data (bytes object size out of range)" );
10901090 break ;
10911091 }
10921092 v = PyBytes_FromStringAndSize ((char * )NULL , n );
@@ -1110,7 +1110,7 @@ r_object(RFILE *p)
11101110 if (PyErr_Occurred ())
11111111 break ;
11121112 if (n < 0 || n > SIZE32_MAX ) {
1113- PyErr_SetString (PyExc_ValueError , "bad marshal data (unicode size out of range)" );
1113+ PyErr_SetString (PyExc_ValueError , "bad marshal data (string size out of range)" );
11141114 break ;
11151115 }
11161116 goto _read_ascii ;
@@ -1150,7 +1150,7 @@ r_object(RFILE *p)
11501150 if (PyErr_Occurred ())
11511151 break ;
11521152 if (n < 0 || n > SIZE32_MAX ) {
1153- PyErr_SetString (PyExc_ValueError , "bad marshal data (unicode size out of range)" );
1153+ PyErr_SetString (PyExc_ValueError , "bad marshal data (string size out of range)" );
11541154 break ;
11551155 }
11561156 if (n != 0 ) {
@@ -1612,7 +1612,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
16121612 if (wf .ptr - base > PY_SSIZE_T_MAX ) {
16131613 Py_DECREF (wf .str );
16141614 PyErr_SetString (PyExc_OverflowError ,
1615- "too much marshal data for a string " );
1615+ "too much marshal data for a bytes object " );
16161616 return NULL ;
16171617 }
16181618 if (_PyBytes_Resize (& wf .str , (Py_ssize_t )(wf .ptr - base )) < 0 )
@@ -1658,8 +1658,7 @@ PyDoc_STRVAR(dump_doc,
16581658"dump(value, file[, version])\n\
16591659\n\
16601660Write the value on the open file. The value must be a supported type.\n\
1661- The file must be an open file object such as sys.stdout or returned by\n\
1662- open() or os.popen(). It must be opened in binary mode ('wb' or 'w+b').\n\
1661+ The file must be a writeable binary file.\n\
16631662\n\
16641663If the value has (or contains an object that has) an unsupported type, a\n\
16651664ValueError exception is raised - but garbage data will also be written\n\
@@ -1715,8 +1714,7 @@ PyDoc_STRVAR(load_doc,
17151714Read one value from the open file and return it. If no valid value is\n\
17161715read (e.g. because the data has a different Python version's\n\
17171716incompatible marshal format), raise EOFError, ValueError or TypeError.\n\
1718- The file must be an open file object opened in binary mode ('rb' or\n\
1719- 'r+b').\n\
1717+ The file must be a readable binary file.\n\
17201718\n\
17211719Note: If an object containing an unsupported type was marshalled with\n\
17221720dump(), load() will substitute None for the unmarshallable type." );
@@ -1735,7 +1733,7 @@ marshal_dumps(PyObject *self, PyObject *args)
17351733PyDoc_STRVAR (dumps_doc ,
17361734"dumps(value[, version])\n\
17371735\n\
1738- Return the string that would be written to a file by dump(value, file).\n\
1736+ Return the bytes object that would be written to a file by dump(value, file).\n\
17391737The value must be a supported type. Raise a ValueError exception if\n\
17401738value has (or contains an object that has) an unsupported type.\n\
17411739\n\
@@ -1771,8 +1769,8 @@ marshal_loads(PyObject *self, PyObject *args)
17711769PyDoc_STRVAR (loads_doc ,
17721770"loads(bytes)\n\
17731771\n\
1774- Convert the bytes object to a value. If no valid value is found, raise \n\
1775- EOFError, ValueError or TypeError. Extra characters in the input are\n\
1772+ Convert the bytes-like object to a value. If no valid value is found,\n\
1773+ raise EOFError, ValueError or TypeError. Extra bytes in the input are\n\
17761774ignored." );
17771775
17781776static PyMethodDef marshal_methods [] = {
@@ -1810,8 +1808,8 @@ Functions:\n\
18101808\n\
18111809dump() -- write value to a file\n\
18121810load() -- read value from a file\n\
1813- dumps() -- write value to a string \n\
1814- loads() -- read value from a string " );
1811+ dumps() -- marshal value as a bytes object \n\
1812+ loads() -- read value from a bytes-like object " );
18151813
18161814
18171815
0 commit comments