Rename PyUnicode_AsString -> _PyUnicode_AsString and
PyUnicode_AsStringAndSize -> _PyUnicode_AsStringAndSize to mark
them for interpreter internal use only.
We'll have to rework these APIs or create new ones for the
purpose of accessing the UTF-8 representation of Unicode objects
for 3.1.
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index eeae0ff..7c1469c 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3230,7 +3230,7 @@
if (!result)
return NULL;
- buf = PyUnicode_AsString(result);
+ buf = _PyUnicode_AsString(result);
if (!buf) {
Py_DECREF(result);
return NULL;
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index cb8f3e4..01a637a 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -296,7 +296,7 @@
if (co->co_firstlineno != 0)
lineno = co->co_firstlineno;
if (co->co_filename && PyUnicode_Check(co->co_filename))
- filename = PyUnicode_AsString(co->co_filename);
+ filename = _PyUnicode_AsString(co->co_filename);
return PyUnicode_FromFormat(
"<code object %.100U at %p, file \"%.300s\", line %d>",
co->co_name, co, filename, lineno);
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 02a55c1..52869cb 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -943,7 +943,7 @@
lineno here */
if (self->filename && PyUnicode_Check(self->filename)) {
- filename = PyUnicode_AsString(self->filename);
+ filename = _PyUnicode_AsString(self->filename);
}
have_lineno = (self->lineno != NULL) && PyLong_CheckExact(self->lineno);
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index efad212..4478168 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1229,7 +1229,7 @@
* exp+4*ndigits and exp-4*ndigits are within the range of a long.
*/
- s = PyUnicode_AsStringAndSize(arg, &length);
+ s = _PyUnicode_AsStringAndSize(arg, &length);
if (s == NULL)
return NULL;
s_end = s + length;
@@ -1597,7 +1597,7 @@
Py_TYPE(arg)->tp_name);
return NULL;
}
- s = PyUnicode_AsString(arg);
+ s = _PyUnicode_AsString(arg);
if (s == NULL)
return NULL;
if (strcmp(s, "double") == 0) {
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index fddb120..594e524 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -297,7 +297,7 @@
PyErr_Format(PyExc_ValueError,
"%s() requires a code object with %zd free vars,"
" not %zd",
- PyUnicode_AsString(op->func_name),
+ _PyUnicode_AsString(op->func_name),
nclosure, nfree);
return -1;
}
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 228ffee..ae01651 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -187,7 +187,7 @@
PyErr_SetString(PyExc_SystemError, "nameless module");
return NULL;
}
- return PyUnicode_AsString(nameobj);
+ return _PyUnicode_AsString(nameobj);
}
const char *
@@ -207,7 +207,7 @@
PyErr_SetString(PyExc_SystemError, "module filename missing");
return NULL;
}
- return PyUnicode_AsString(fileobj);
+ return _PyUnicode_AsString(fileobj);
}
PyModuleDef*
@@ -252,7 +252,7 @@
pos = 0;
while (PyDict_Next(d, &pos, &key, &value)) {
if (value != Py_None && PyUnicode_Check(key)) {
- const char *s = PyUnicode_AsString(key);
+ const char *s = _PyUnicode_AsString(key);
if (s[0] == '_' && s[1] != '_') {
if (Py_VerboseFlag > 1)
PySys_WriteStderr("# clear[1] %s\n", s);
@@ -265,7 +265,7 @@
pos = 0;
while (PyDict_Next(d, &pos, &key, &value)) {
if (value != Py_None && PyUnicode_Check(key)) {
- const char *s = PyUnicode_AsString(key);
+ const char *s = _PyUnicode_AsString(key);
if (s[0] != '_' || strcmp(s, "__builtins__") != 0) {
if (Py_VerboseFlag > 1)
PySys_WriteStderr("# clear[2] %s\n", s);
diff --git a/Objects/object.c b/Objects/object.c
index ff16994..79f8288 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -856,7 +856,7 @@
if (tp->tp_getattro != NULL)
return (*tp->tp_getattro)(v, name);
if (tp->tp_getattr != NULL)
- return (*tp->tp_getattr)(v, PyUnicode_AsString(name));
+ return (*tp->tp_getattr)(v, _PyUnicode_AsString(name));
PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%U'",
tp->tp_name, name);
@@ -896,7 +896,7 @@
return err;
}
if (tp->tp_setattr != NULL) {
- err = (*tp->tp_setattr)(v, PyUnicode_AsString(name), value);
+ err = (*tp->tp_setattr)(v, _PyUnicode_AsString(name), value);
Py_DECREF(name);
return err;
}
@@ -1062,7 +1062,7 @@
PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyUnicode_AsString(name));
+ tp->tp_name, _PyUnicode_AsString(name));
done:
Py_DECREF(name);
return res;
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 771f47e..1054166 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -2390,7 +2390,7 @@
/* Exercise direct iteration */
i = 0, count = 0;
while (_PySet_NextEntry((PyObject *)dup, &i, &x, &hash)) {
- s = PyUnicode_AsString(x);
+ s = _PyUnicode_AsString(x);
assert(s && (s[0] == 'a' || s[0] == 'b' || s[0] == 'c'));
count++;
}
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 56e885c..091370c 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -270,7 +270,7 @@
Py_DECREF(tup);
return NULL;
}
- crepr = PyUnicode_AsString(repr);
+ crepr = _PyUnicode_AsString(repr);
if (crepr == NULL) {
Py_DECREF(tup);
Py_DECREF(repr);
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 9306552..616164e 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -258,7 +258,7 @@
}
Py_DECREF(tmp);
- tp_name = PyUnicode_AsString(value);
+ tp_name = _PyUnicode_AsString(value);
if (tp_name == NULL)
return -1;
@@ -1255,7 +1255,7 @@
o = class_name(o);
PyErr_Format(PyExc_TypeError,
"duplicate base class %.400s",
- o ? PyUnicode_AsString(o) : "?");
+ o ? _PyUnicode_AsString(o) : "?");
Py_XDECREF(o);
return -1;
}
@@ -1301,7 +1301,7 @@
while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) {
PyObject *name = class_name(k);
off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s",
- name ? PyUnicode_AsString(name) : "?");
+ name ? _PyUnicode_AsString(name) : "?");
Py_XDECREF(name);
if (--n && (size_t)(off+1) < sizeof(buf)) {
buf[off++] = ',';
@@ -2094,7 +2094,7 @@
type->tp_as_sequence = &et->as_sequence;
type->tp_as_mapping = &et->as_mapping;
type->tp_as_buffer = &et->as_buffer;
- type->tp_name = PyUnicode_AsString(name);
+ type->tp_name = _PyUnicode_AsString(name);
if (!type->tp_name) {
Py_DECREF(type);
return NULL;
@@ -2136,7 +2136,7 @@
char *doc_str;
char *tp_doc;
- doc_str = PyUnicode_AsStringAndSize(doc, &len);
+ doc_str = _PyUnicode_AsStringAndSize(doc, &len);
if (doc_str == NULL) {
Py_DECREF(type);
return NULL;
@@ -2175,7 +2175,7 @@
slotoffset = base->tp_basicsize;
if (slots != NULL) {
for (i = 0; i < nslots; i++, mp++) {
- mp->name = PyUnicode_AsString(
+ mp->name = _PyUnicode_AsString(
PyTuple_GET_ITEM(slots, i));
mp->type = T_OBJECT_EX;
mp->offset = slotoffset;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 5925f80..5bf0fa2 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1452,7 +1452,7 @@
}
char*
-PyUnicode_AsStringAndSize(PyObject *unicode, Py_ssize_t *psize)
+_PyUnicode_AsStringAndSize(PyObject *unicode, Py_ssize_t *psize)
{
PyObject *bytes;
if (!PyUnicode_Check(unicode)) {
@@ -1468,9 +1468,9 @@
}
char*
-PyUnicode_AsString(PyObject *unicode)
+_PyUnicode_AsString(PyObject *unicode)
{
- return PyUnicode_AsStringAndSize(unicode, NULL);
+ return _PyUnicode_AsStringAndSize(unicode, NULL);
}
Py_UNICODE *PyUnicode_AsUnicode(PyObject *unicode)
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 6ceed73..83e63fc 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -167,7 +167,7 @@
if (nameobj == NULL)
PyErr_Clear();
else if (PyUnicode_Check(nameobj))
- name = PyUnicode_AsString(nameobj);
+ name = _PyUnicode_AsString(nameobj);
PyOS_snprintf(buffer, sizeof(buffer),
name ? "<weakref at %p; to '%.50s' at %p (%s)>"
: "<weakref at %p; to '%.50s' at %p>",