@@ -549,7 +549,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p)
549
549
w_object (co -> co_lnotab , p );
550
550
}
551
551
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 */
553
553
Py_buffer view ;
554
554
if (PyObject_GetBuffer (v , & view , PyBUF_SIMPLE ) != 0 ) {
555
555
w_byte (TYPE_UNKNOWN , p );
@@ -1086,7 +1086,7 @@ r_object(RFILE *p)
1086
1086
if (PyErr_Occurred ())
1087
1087
break ;
1088
1088
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)" );
1090
1090
break ;
1091
1091
}
1092
1092
v = PyBytes_FromStringAndSize ((char * )NULL , n );
@@ -1110,7 +1110,7 @@ r_object(RFILE *p)
1110
1110
if (PyErr_Occurred ())
1111
1111
break ;
1112
1112
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)" );
1114
1114
break ;
1115
1115
}
1116
1116
goto _read_ascii ;
@@ -1150,7 +1150,7 @@ r_object(RFILE *p)
1150
1150
if (PyErr_Occurred ())
1151
1151
break ;
1152
1152
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)" );
1154
1154
break ;
1155
1155
}
1156
1156
if (n != 0 ) {
@@ -1612,7 +1612,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
1612
1612
if (wf .ptr - base > PY_SSIZE_T_MAX ) {
1613
1613
Py_DECREF (wf .str );
1614
1614
PyErr_SetString (PyExc_OverflowError ,
1615
- "too much marshal data for a string " );
1615
+ "too much marshal data for a bytes object " );
1616
1616
return NULL ;
1617
1617
}
1618
1618
if (_PyBytes_Resize (& wf .str , (Py_ssize_t )(wf .ptr - base )) < 0 )
@@ -1658,8 +1658,7 @@ PyDoc_STRVAR(dump_doc,
1658
1658
"dump(value, file[, version])\n\
1659
1659
\n\
1660
1660
Write 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\
1663
1662
\n\
1664
1663
If the value has (or contains an object that has) an unsupported type, a\n\
1665
1664
ValueError exception is raised - but garbage data will also be written\n\
@@ -1715,8 +1714,7 @@ PyDoc_STRVAR(load_doc,
1715
1714
Read one value from the open file and return it. If no valid value is\n\
1716
1715
read (e.g. because the data has a different Python version's\n\
1717
1716
incompatible 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\
1720
1718
\n\
1721
1719
Note: If an object containing an unsupported type was marshalled with\n\
1722
1720
dump(), load() will substitute None for the unmarshallable type." );
@@ -1735,7 +1733,7 @@ marshal_dumps(PyObject *self, PyObject *args)
1735
1733
PyDoc_STRVAR (dumps_doc ,
1736
1734
"dumps(value[, version])\n\
1737
1735
\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\
1739
1737
The value must be a supported type. Raise a ValueError exception if\n\
1740
1738
value has (or contains an object that has) an unsupported type.\n\
1741
1739
\n\
@@ -1771,8 +1769,8 @@ marshal_loads(PyObject *self, PyObject *args)
1771
1769
PyDoc_STRVAR (loads_doc ,
1772
1770
"loads(bytes)\n\
1773
1771
\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\
1776
1774
ignored." );
1777
1775
1778
1776
static PyMethodDef marshal_methods [] = {
@@ -1810,8 +1808,8 @@ Functions:\n\
1810
1808
\n\
1811
1809
dump() -- write value to a file\n\
1812
1810
load() -- 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 " );
1815
1813
1816
1814
1817
1815
0 commit comments