mirror of https://github.com/python/cpython
Clean up PyString_Size().
Removed string_getsize(), since it was only useful when PyString_AsStringAndSize was able to convert an (ascii) Unicode object to a C string.
This commit is contained in:
parent
5dfe0def67
commit
ad433db9b4
|
@ -494,25 +494,18 @@ PyObject *PyString_DecodeEscape(const char *s,
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* object api */
|
/* object api */
|
||||||
|
|
||||||
static Py_ssize_t
|
|
||||||
string_getsize(register PyObject *op)
|
|
||||||
{
|
|
||||||
char *s;
|
|
||||||
Py_ssize_t len;
|
|
||||||
if (PyString_AsStringAndSize(op, &s, &len))
|
|
||||||
return -1;
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_ssize_t
|
Py_ssize_t
|
||||||
PyString_Size(register PyObject *op)
|
PyString_Size(register PyObject *op)
|
||||||
{
|
{
|
||||||
if (!PyString_Check(op))
|
if (!PyString_Check(op)) {
|
||||||
return string_getsize(op);
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"expected bytes, %.200s found", Py_TYPE(op)->tp_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return Py_SIZE(op);
|
return Py_SIZE(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*const*/ char *
|
char *
|
||||||
PyString_AsString(register PyObject *op)
|
PyString_AsString(register PyObject *op)
|
||||||
{
|
{
|
||||||
if (!PyString_Check(op)) {
|
if (!PyString_Check(op)) {
|
||||||
|
|
Loading…
Reference in New Issue