mirror of
https://github.com/python/cpython.git
synced 2025-11-11 22:55:08 +00:00
Forgot to submit this earlier; it's needed to make test_threading pass.
This commit is contained in:
parent
65b6a80f19
commit
867bcbcd6d
1 changed files with 4 additions and 4 deletions
|
|
@ -797,14 +797,14 @@ CharArray_set_value(CDataObject *self, PyObject *value)
|
||||||
conversion_mode_errors);
|
conversion_mode_errors);
|
||||||
if (!value)
|
if (!value)
|
||||||
return -1;
|
return -1;
|
||||||
} else if (!PyString_Check(value)) {
|
} else if (!PyBytes_Check(value)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"string expected instead of %s instance",
|
"str/bytes expected instead of %s instance",
|
||||||
value->ob_type->tp_name);
|
value->ob_type->tp_name);
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
size = PyString_GET_SIZE(value);
|
size = PyBytes_GET_SIZE(value);
|
||||||
if (size > self->b_size) {
|
if (size > self->b_size) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"string too long");
|
"string too long");
|
||||||
|
|
@ -812,7 +812,7 @@ CharArray_set_value(CDataObject *self, PyObject *value)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = PyString_AS_STRING(value);
|
ptr = PyBytes_AS_STRING(value);
|
||||||
memcpy(self->b_ptr, ptr, size);
|
memcpy(self->b_ptr, ptr, size);
|
||||||
if (size < self->b_size)
|
if (size < self->b_size)
|
||||||
self->b_ptr[size] = '\0';
|
self->b_ptr[size] = '\0';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue