@@ -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 );
@@ -1079,7 +1079,7 @@ r_object(RFILE *p)
1079
1079
if (PyErr_Occurred ())
1080
1080
break ;
1081
1081
if (n < 0 || n > SIZE32_MAX ) {
1082
- PyErr_SetString (PyExc_ValueError , "bad marshal data (string size out of range)" );
1082
+ PyErr_SetString (PyExc_ValueError , "bad marshal data (bytes object size out of range)" );
1083
1083
break ;
1084
1084
}
1085
1085
v = PyBytes_FromStringAndSize ((char * )NULL , n );
@@ -1103,7 +1103,7 @@ r_object(RFILE *p)
1103
1103
if (PyErr_Occurred ())
1104
1104
break ;
1105
1105
if (n < 0 || n > SIZE32_MAX ) {
1106
- PyErr_SetString (PyExc_ValueError , "bad marshal data (unicode size out of range)" );
1106
+ PyErr_SetString (PyExc_ValueError , "bad marshal data (string size out of range)" );
1107
1107
break ;
1108
1108
}
1109
1109
goto _read_ascii ;
@@ -1143,7 +1143,7 @@ r_object(RFILE *p)
1143
1143
if (PyErr_Occurred ())
1144
1144
break ;
1145
1145
if (n < 0 || n > SIZE32_MAX ) {
1146
- PyErr_SetString (PyExc_ValueError , "bad marshal data (unicode size out of range)" );
1146
+ PyErr_SetString (PyExc_ValueError , "bad marshal data (string size out of range)" );
1147
1147
break ;
1148
1148
}
1149
1149
if (n != 0 ) {
@@ -1594,7 +1594,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
1594
1594
if (wf .ptr - base > PY_SSIZE_T_MAX ) {
1595
1595
Py_DECREF (wf .str );
1596
1596
PyErr_SetString (PyExc_OverflowError ,
1597
- "too much marshal data for a string " );
1597
+ "too much marshal data for a bytes object " );
1598
1598
return NULL ;
1599
1599
}
1600
1600
if (_PyBytes_Resize (& wf .str , (Py_ssize_t )(wf .ptr - base )) < 0 )
@@ -1640,8 +1640,7 @@ PyDoc_STRVAR(dump_doc,
1640
1640
"dump(value, file[, version])\n\
1641
1641
\n\
1642
1642
Write the value on the open file. The value must be a supported type.\n\
1643
- The file must be an open file object such as sys.stdout or returned by\n\
1644
- open() or os.popen(). It must be opened in binary mode ('wb' or 'w+b').\n\
1643
+ The file must be a writeable binary file.\n\
1645
1644
\n\
1646
1645
If the value has (or contains an object that has) an unsupported type, a\n\
1647
1646
ValueError exception is raised - but garbage data will also be written\n\
@@ -1697,8 +1696,7 @@ PyDoc_STRVAR(load_doc,
1697
1696
Read one value from the open file and return it. If no valid value is\n\
1698
1697
read (e.g. because the data has a different Python version's\n\
1699
1698
incompatible marshal format), raise EOFError, ValueError or TypeError.\n\
1700
- The file must be an open file object opened in binary mode ('rb' or\n\
1701
- 'r+b').\n\
1699
+ The file must be a readable binary file.\n\
1702
1700
\n\
1703
1701
Note: If an object containing an unsupported type was marshalled with\n\
1704
1702
dump(), load() will substitute None for the unmarshallable type." );
@@ -1717,7 +1715,7 @@ marshal_dumps(PyObject *self, PyObject *args)
1717
1715
PyDoc_STRVAR (dumps_doc ,
1718
1716
"dumps(value[, version])\n\
1719
1717
\n\
1720
- Return the string that would be written to a file by dump(value, file).\n\
1718
+ Return the bytes object that would be written to a file by dump(value, file).\n\
1721
1719
The value must be a supported type. Raise a ValueError exception if\n\
1722
1720
value has (or contains an object that has) an unsupported type.\n\
1723
1721
\n\
@@ -1753,8 +1751,8 @@ marshal_loads(PyObject *self, PyObject *args)
1753
1751
PyDoc_STRVAR (loads_doc ,
1754
1752
"loads(bytes)\n\
1755
1753
\n\
1756
- Convert the bytes object to a value. If no valid value is found, raise \n\
1757
- EOFError, ValueError or TypeError. Extra characters in the input are\n\
1754
+ Convert the bytes-like object to a value. If no valid value is found,\n\
1755
+ raise EOFError, ValueError or TypeError. Extra bytes in the input are\n\
1758
1756
ignored." );
1759
1757
1760
1758
static PyMethodDef marshal_methods [] = {
@@ -1792,8 +1790,8 @@ Functions:\n\
1792
1790
\n\
1793
1791
dump() -- write value to a file\n\
1794
1792
load() -- read value from a file\n\
1795
- dumps() -- write value to a string \n\
1796
- loads() -- read value from a string " );
1793
+ dumps() -- marshal value as a bytes object \n\
1794
+ loads() -- read value from a bytes-like object " );
1797
1795
1798
1796
1799
1797
0 commit comments