mirror of
https://github.com/python/cpython.git
synced 2025-09-11 11:17:16 +00:00
More coding by random modification.
Encoding now return bytes instead of str8. eval(), exec(), compile() now accept unicode or bytes.
This commit is contained in:
parent
bae5cedb8d
commit
f15a29f975
12 changed files with 185 additions and 155 deletions
|
@ -263,14 +263,14 @@ w_object(PyObject *v, WFILE *p)
|
|||
return;
|
||||
}
|
||||
w_byte(TYPE_UNICODE, p);
|
||||
n = PyString_GET_SIZE(utf8);
|
||||
n = PyBytes_GET_SIZE(utf8);
|
||||
if (n > INT_MAX) {
|
||||
p->depth--;
|
||||
p->error = 1;
|
||||
return;
|
||||
}
|
||||
w_long((long)n, p);
|
||||
w_string(PyString_AS_STRING(utf8), (int)n, p);
|
||||
w_string(PyBytes_AS_STRING(utf8), (int)n, p);
|
||||
Py_DECREF(utf8);
|
||||
}
|
||||
else if (PyTuple_Check(v)) {
|
||||
|
@ -1031,7 +1031,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
|
|||
if (wf.ptr - base > PY_SSIZE_T_MAX) {
|
||||
Py_DECREF(wf.str);
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"too much marshall data for a string");
|
||||
"too much marshal data for a string");
|
||||
return NULL;
|
||||
}
|
||||
_PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue