summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2008-01-07 02:06:10 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2008-01-07 02:06:10 (GMT)
commitad433db9b40a8ca829dae35cf835386629ec0399 (patch)
tree3e115ff16dc8e928d74b6eacf264af137dcae700 /Objects
parent5dfe0def6711d0e59cd1949e842c3d9dd32b4e4f (diff)
downloadcpython-ad433db9b40a8ca829dae35cf835386629ec0399.zip
cpython-ad433db9b40a8ca829dae35cf835386629ec0399.tar.gz
cpython-ad433db9b40a8ca829dae35cf835386629ec0399.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringobject.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 0125a99..011fc32 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -494,25 +494,18 @@ PyObject *PyString_DecodeEscape(const char *s,
/* -------------------------------------------------------------------- */
/* 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
PyString_Size(register PyObject *op)
{
- if (!PyString_Check(op))
- return string_getsize(op);
+ if (!PyString_Check(op)) {
+ PyErr_Format(PyExc_TypeError,
+ "expected bytes, %.200s found", Py_TYPE(op)->tp_name);
+ return -1;
+ }
return Py_SIZE(op);
}
-/*const*/ char *
+char *
PyString_AsString(register PyObject *op)
{
if (!PyString_Check(op)) {
@@ -520,7 +513,7 @@ PyString_AsString(register PyObject *op)
"expected bytes, %.200s found", Py_TYPE(op)->tp_name);
return NULL;
}
- return ((PyStringObject *)op) -> ob_sval;
+ return ((PyStringObject *)op)->ob_sval;
}
int