summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2008-08-07 18:54:33 +0000
committerMarc-André Lemburg <mal@egenix.com>2008-08-07 18:54:33 +0000
commit9474310515fdfc07d315230fd7039ce912afb002 (patch)
tree90302a8176bf837998f2454d8ef422ca3de3c7f9
parenta71903fb010d90a76a800d9f6f5713f2e2136817 (diff)
downloadcpython-9474310515fdfc07d315230fd7039ce912afb002.tar.gz
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.
-rw-r--r--Include/object.h2
-rw-r--r--Include/unicodeobject.h19
-rw-r--r--Misc/NEWS8
-rw-r--r--Modules/_ctypes/_ctypes.c18
-rw-r--r--Modules/_ctypes/callproc.c2
-rw-r--r--Modules/_ctypes/stgdict.c2
-rw-r--r--Modules/_elementtree.c4
-rw-r--r--Modules/_gestalt.c2
-rw-r--r--Modules/_hashopenssl.c2
-rw-r--r--Modules/_lsprof.c2
-rw-r--r--Modules/_pickle.c6
-rw-r--r--Modules/_sqlite/connection.c8
-rw-r--r--Modules/_sqlite/cursor.c4
-rw-r--r--Modules/_sqlite/row.c4
-rw-r--r--Modules/_sqlite/statement.c6
-rw-r--r--Modules/_ssl.c2
-rw-r--r--Modules/_struct.c2
-rw-r--r--Modules/_testcapimodule.c2
-rw-r--r--Modules/_tkinter.c2
-rw-r--r--Modules/cjkcodecs/cjkcodecs.h2
-rw-r--r--Modules/cjkcodecs/multibytecodec.c4
-rw-r--r--Modules/datetimemodule.c4
-rw-r--r--Modules/grpmodule.c2
-rw-r--r--Modules/operator.c2
-rw-r--r--Modules/ossaudiodev.c2
-rw-r--r--Modules/parsermodule.c4
-rw-r--r--Modules/posixmodule.c4
-rw-r--r--Modules/pyexpat.c2
-rw-r--r--Modules/readline.c2
-rw-r--r--Modules/socketmodule.c2
-rw-r--r--Modules/syslogmodule.c4
-rw-r--r--Modules/timemodule.c2
-rw-r--r--Modules/zipimport.c26
-rw-r--r--Objects/bytesobject.c2
-rw-r--r--Objects/codeobject.c2
-rw-r--r--Objects/exceptions.c2
-rw-r--r--Objects/floatobject.c4
-rw-r--r--Objects/funcobject.c2
-rw-r--r--Objects/moduleobject.c8
-rw-r--r--Objects/object.c6
-rw-r--r--Objects/setobject.c2
-rw-r--r--Objects/structseq.c2
-rw-r--r--Objects/typeobject.c12
-rw-r--r--Objects/unicodeobject.c6
-rw-r--r--Objects/weakrefobject.c2
-rw-r--r--Parser/tokenizer.c2
-rw-r--r--Python/_warnings.c18
-rw-r--r--Python/ast.c2
-rw-r--r--Python/bltinmodule.c4
-rw-r--r--Python/ceval.c8
-rw-r--r--Python/compile.c2
-rw-r--r--Python/errors.c2
-rw-r--r--Python/future.c2
-rw-r--r--Python/getargs.c2
-rw-r--r--Python/import.c14
-rw-r--r--Python/peephole.c2
-rw-r--r--Python/pythonrun.c16
-rw-r--r--Python/structmember.c2
-rw-r--r--Python/symtable.c4
-rw-r--r--Python/traceback.c4
60 files changed, 156 insertions, 137 deletions
diff --git a/Include/object.h b/Include/object.h
index 07a4b2c89d..f5ec7d49a7 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -466,7 +466,7 @@ PyAPI_FUNC(long) _Py_HashDouble(double);
PyAPI_FUNC(long) _Py_HashPointer(void*);
/* Helper for passing objects to printf and the like */
-#define PyObject_REPR(obj) PyUnicode_AsString(PyObject_Repr(obj))
+#define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
/* Flag bits for printing: */
#define Py_PRINT_RAW 1 /* No string quotes etc. */
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index d5b657292a..c2360d35bf 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -704,9 +704,15 @@ PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefaultAndSize(
In case of an error, no *size is set.
+ *** This API is for interpreter INTERNAL USE ONLY and will likely
+ *** be removed or changed for Python 3.1.
+
+ *** If you need to access the Unicode object as UTF-8 bytes string,
+ *** please use PyUnicode_AsUTF8String() instead.
+
*/
-PyAPI_FUNC(char *) PyUnicode_AsStringAndSize(
+PyAPI_FUNC(char *) _PyUnicode_AsStringAndSize(
PyObject *unicode,
Py_ssize_t *size);
@@ -714,12 +720,17 @@ PyAPI_FUNC(char *) PyUnicode_AsStringAndSize(
Unicode object unicode.
Use of this API is DEPRECATED since no size information can be
- extracted from the returned data. Use PyUnicode_AsStringAndSize()
- instead.
+ extracted from the returned data.
+
+ *** This API is for interpreter INTERNAL USE ONLY and will likely
+ *** be removed or changed for Python 3.1.
+
+ *** If you need to access the Unicode object as UTF-8 bytes string,
+ *** please use PyUnicode_AsUTF8String() instead.
*/
-PyAPI_FUNC(char *) PyUnicode_AsString(PyObject *unicode);
+PyAPI_FUNC(char *) _PyUnicode_AsString(PyObject *unicode);
/* Returns the currently active default encoding.
diff --git a/Misc/NEWS b/Misc/NEWS
index 3679a5b1c5..1e22f70a41 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,14 @@ Core and Builtins
- Issue #1819: function calls with several named parameters are now on
average 35% faster (as measured by pybench).
+- The undocumented C APIs PyUnicode_AsString() and
+ PyUnicode_AsStringAndSize() were made private to the interpreter, in
+ order to be able to refine their interfaces for Python 3.1.
+
+ If you need to access the UTF-8 representation of a Unicode object
+ as bytes string, please use PyUnicode_AsUTF8String() instead.
+
+
Library
-------
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 48fe772508..02a08a40c4 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -683,8 +683,8 @@ StructType_setattro(PyObject *self, PyObject *key, PyObject *value)
return -1;
if (value && PyUnicode_Check(key) &&
- /* XXX struni PyUnicode_AsString can fail (also in other places)! */
- 0 == strcmp(PyUnicode_AsString(key), "_fields_"))
+ /* XXX struni _PyUnicode_AsString can fail (also in other places)! */
+ 0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
return StructUnionType_update_stgdict(self, value, 1);
return 0;
}
@@ -698,7 +698,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value)
return -1;
if (PyUnicode_Check(key) &&
- 0 == strcmp(PyUnicode_AsString(key), "_fields_"))
+ 0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
return StructUnionType_update_stgdict(self, value, 0);
return 0;
}
@@ -1681,7 +1681,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
if (stgd && CDataObject_Check(value) && stgd->proto && PyUnicode_Check(stgd->proto)) {
PyCArgObject *parg;
- switch (PyUnicode_AsString(stgd->proto)[0]) {
+ switch (_PyUnicode_AsString(stgd->proto)[0]) {
case 'z': /* c_char_p */
case 'Z': /* c_wchar_p */
parg = new_CArgObject();
@@ -1791,7 +1791,7 @@ SimpleType_paramfunc(CDataObject *self)
dict = PyObject_stgdict((PyObject *)self);
assert(dict); /* Cannot be NULL for CDataObject instances */
- fmt = PyUnicode_AsString(dict->proto);
+ fmt = _PyUnicode_AsString(dict->proto);
assert(fmt);
fd = getentry(fmt);
@@ -2012,7 +2012,7 @@ SimpleType_from_param(PyObject *type, PyObject *value)
assert(dict);
/* I think we can rely on this being a one-character string */
- fmt = PyUnicode_AsString(dict->proto);
+ fmt = _PyUnicode_AsString(dict->proto);
assert(fmt);
fd = getentry(fmt);
@@ -3058,7 +3058,7 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index)
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
&& PyUnicode_Check(dict->proto)
/* We only allow c_void_p, c_char_p and c_wchar_p as a simple output parameter type */
- && (strchr("PzZ", PyUnicode_AsString(dict->proto)[0]))) {
+ && (strchr("PzZ", _PyUnicode_AsString(dict->proto)[0]))) {
return 1;
}
@@ -3148,7 +3148,7 @@ _get_name(PyObject *obj, char **pname)
return *pname ? 1 : 0;
}
if (PyUnicode_Check(obj)) {
- *pname = PyUnicode_AsString(obj);
+ *pname = _PyUnicode_AsString(obj);
return *pname ? 1 : 0;
}
PyErr_SetString(PyExc_TypeError,
@@ -5127,7 +5127,7 @@ cast_check_pointertype(PyObject *arg)
dict = PyType_stgdict(arg);
if (dict) {
if (PyUnicode_Check(dict->proto)
- && (strchr("sPzUZXO", PyUnicode_AsString(dict->proto)[0]))) {
+ && (strchr("sPzUZXO", _PyUnicode_AsString(dict->proto)[0]))) {
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
return 1;
}
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index d45278580f..6dced06d65 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1750,7 +1750,7 @@ POINTER(PyObject *self, PyObject *cls)
return result;
}
if (PyUnicode_CheckExact(cls)) {
- char *name = PyUnicode_AsString(cls);
+ char *name = _PyUnicode_AsString(cls);
buf = alloca(strlen(name) + 3 + 1);
sprintf(buf, "LP_%s", name);
result = PyObject_CallFunction((PyObject *)Py_TYPE(&Pointer_Type),
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 085b19f508..aac073f9a1 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -479,7 +479,7 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
bitsize = 0;
if (isStruct && !isPacked) {
char *fieldfmt = dict->format ? dict->format : "B";
- char *fieldname = PyUnicode_AsString(name);
+ char *fieldname = _PyUnicode_AsString(name);
char *ptr;
Py_ssize_t len = strlen(fieldname) + strlen(fieldfmt);
char *buf = alloca(len + 2 + 1);
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index da223c4ee0..767c6eebff 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -1303,7 +1303,7 @@ element_getattro(ElementObject* self, PyObject* nameobj)
char *name = "";
if (PyUnicode_Check(nameobj))
- name = PyUnicode_AsString(nameobj);
+ name = _PyUnicode_AsString(nameobj);
if (strcmp(name, "tag") == 0)
res = self->tag;
@@ -2529,7 +2529,7 @@ xmlparser_getattro(XMLParserObject* self, PyObject* nameobj)
char *name = "";
if (PyUnicode_Check(nameobj))
- name = PyUnicode_AsString(nameobj);
+ name = _PyUnicode_AsString(nameobj);
PyErr_Clear();
diff --git a/Modules/_gestalt.c b/Modules/_gestalt.c
index 3a7279f824..462a6d265e 100644
--- a/Modules/_gestalt.c
+++ b/Modules/_gestalt.c
@@ -38,7 +38,7 @@ convert_to_OSType(PyObject *v, OSType *pr)
"OSType arg must be string of 4 chars");
return 0;
}
- memcpy((char *)&tmp, PyUnicode_AsString(v), 4);
+ memcpy((char *)&tmp, _PyUnicode_AsString(v), 4);
*pr = (OSType)ntohl(tmp);
return 1;
}
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 8965f434dc..bd04411113 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -241,7 +241,7 @@ EVP_repr(PyObject *self)
{
char buf[100];
PyOS_snprintf(buf, sizeof(buf), "<%s HASH object @ %p>",
- PyUnicode_AsString(((EVPobject *)self)->name), self);
+ _PyUnicode_AsString(((EVPobject *)self)->name), self);
return PyUnicode_FromString(buf);
}
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 69ecaf101b..a6fd1f802c 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -180,7 +180,7 @@ normalizeUserObj(PyObject *obj)
PyObject *mod = fn->m_module;
const char *modname;
if (mod && PyUnicode_Check(mod)) {
- modname = PyUnicode_AsString(mod);
+ modname = _PyUnicode_AsString(mod);
}
else if (mod && PyModule_Check(mod)) {
modname = PyModule_GetName(mod);
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 98cb62e1ed..0f5b06bea8 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -927,7 +927,7 @@ save_long(PicklerObject *self, PyObject *obj)
repr = PyUnicode_FromStringAndSize(NULL, (int)nbytes);
if (repr == NULL)
goto error;
- pdata = (unsigned char *)PyUnicode_AsString(repr);
+ pdata = (unsigned char *)_PyUnicode_AsString(repr);
i = _PyLong_AsByteArray((PyLongObject *)obj,
pdata, nbytes,
1 /* little endian */ , 1 /* signed */ );
@@ -972,7 +972,7 @@ save_long(PicklerObject *self, PyObject *obj)
if (repr == NULL)
goto error;
- string = PyUnicode_AsStringAndSize(repr, &size);
+ string = _PyUnicode_AsStringAndSize(repr, &size);
if (string == NULL)
goto error;
@@ -1869,7 +1869,7 @@ save_pers(PicklerObject *self, PyObject *obj, PyObject *func)
/* XXX: Should it check whether the persistent id only contains
ASCII characters? And what if the pid contains embedded
newlines? */
- pid_ascii_bytes = PyUnicode_AsStringAndSize(pid_str, &size);
+ pid_ascii_bytes = _PyUnicode_AsStringAndSize(pid_str, &size);
Py_DECREF(pid_str);
if (pid_ascii_bytes == NULL)
goto error;
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 1e529187cb..7b931c0b9c 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -434,7 +434,7 @@ void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
} else if (PyFloat_Check(py_val)) {
sqlite3_result_double(context, PyFloat_AsDouble(py_val));
} else if (PyUnicode_Check(py_val)) {
- sqlite3_result_text(context, PyUnicode_AsString(py_val), -1, SQLITE_TRANSIENT);
+ sqlite3_result_text(context, _PyUnicode_AsString(py_val), -1, SQLITE_TRANSIENT);
} else if (PyObject_CheckBuffer(py_val)) {
if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) {
PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
@@ -901,7 +901,7 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
return -1;
}
- statement = PyUnicode_AsStringAndSize(begin_statement, &size);
+ statement = _PyUnicode_AsStringAndSize(begin_statement, &size);
if (!statement) {
Py_DECREF(statement);
return -1;
@@ -1194,7 +1194,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
goto finally;
}
- chk = PyUnicode_AsString(uppercase_name);
+ chk = _PyUnicode_AsString(uppercase_name);
while (*chk) {
if ((*chk >= '0' && *chk <= '9')
|| (*chk >= 'A' && *chk <= 'Z')
@@ -1219,7 +1219,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
}
rc = sqlite3_create_collation(self->db,
- PyUnicode_AsString(uppercase_name),
+ _PyUnicode_AsString(uppercase_name),
SQLITE_UTF8,
(callable != Py_None) ? callable : NULL,
(callable != Py_None) ? pysqlite_collation_callback : NULL);
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 14dd002165..9ac25f5cc0 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -490,7 +490,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
rc = pysqlite_statement_reset(self->statement);
}
- operation_cstr = PyUnicode_AsStringAndSize(operation, &operation_len);
+ operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
if (operation == NULL)
goto error;
@@ -793,7 +793,7 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
}
if (PyUnicode_Check(script_obj)) {
- script_cstr = PyUnicode_AsString(script_obj);
+ script_cstr = _PyUnicode_AsString(script_obj);
if (!script_cstr) {
return NULL;
}
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 008f19e523..8778af0a96 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -82,12 +82,12 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
Py_XINCREF(item);
return item;
} else if (PyUnicode_Check(idx)) {
- key = PyUnicode_AsString(idx);
+ key = _PyUnicode_AsString(idx);
nitems = PyTuple_Size(self->description);
for (i = 0; i < nitems; i++) {
- compare_key = PyUnicode_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0));
+ compare_key = _PyUnicode_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0));
if (!compare_key) {
return NULL;
}
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index fb1eec7c0f..d2f3c1ea05 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -59,7 +59,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
self->st = NULL;
self->in_use = 0;
- sql_cstr = PyUnicode_AsStringAndSize(sql, &sql_cstr_len);
+ sql_cstr = _PyUnicode_AsStringAndSize(sql, &sql_cstr_len);
if (sql_cstr == NULL) {
rc = PYSQLITE_SQL_WRONG_TYPE;
return rc;
@@ -140,7 +140,7 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
break;
case TYPE_UNICODE:
- string = PyUnicode_AsString(parameter);
+ string = _PyUnicode_AsString(parameter);
rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
break;
case TYPE_BUFFER:
@@ -296,7 +296,7 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
Py_ssize_t sql_len;
sqlite3_stmt* new_st;
- sql_cstr = PyUnicode_AsStringAndSize(self->sql, &sql_len);
+ sql_cstr = _PyUnicode_AsStringAndSize(self->sql, &sql_len);
if (sql_cstr == NULL) {
rc = PYSQLITE_SQL_WRONG_TYPE;
return rc;
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 25b82b44d6..48318a8abc 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1461,7 +1461,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg)
return PyErr_Format(PyExc_TypeError,
"RAND_egd() expected string, found %s",
Py_TYPE(arg)->tp_name);
- bytes = RAND_egd(PyUnicode_AsString(arg));
+ bytes = RAND_egd(_PyUnicode_AsString(arg));
if (bytes == -1) {
PyErr_SetString(PySSLErrorObject,
"EGD connection failed or EGD did not return "
diff --git a/Modules/_struct.c b/Modules/_struct.c
index a1e56bee63..43be9ed0a5 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -406,7 +406,7 @@ _range_error(const formatdef *f, int is_unsigned)
if (msg == NULL)
return -1;
rval = PyErr_WarnEx(PyExc_DeprecationWarning,
- PyUnicode_AsString(msg), 2);
+ _PyUnicode_AsString(msg), 2);
Py_DECREF(msg);
if (rval == 0)
return 0;
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 45494dd5c6..3ee3bf4d01 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -788,7 +788,7 @@ test_string_from_format(PyObject *self, PyObject *args)
result = PyUnicode_FromFormat(FORMAT, (TYPE)1); \
if (result == NULL) \
return NULL; \
- if (strcmp(PyUnicode_AsString(result), "1")) { \
+ if (strcmp(_PyUnicode_AsString(result), "1")) { \
msg = FORMAT " failed at 1"; \
goto Fail; \
} \
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 4e36daccd3..3bbc7e4c39 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -1424,7 +1424,7 @@ varname_converter(PyObject *in, void *_out)
return 1;
}
if (PyUnicode_Check(in)) {
- *out = PyUnicode_AsString(in);
+ *out = _PyUnicode_AsString(in);
return 1;
}
if (PyTclObject_Check(in)) {
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
index 89c644cd04..0530a33ab1 100644
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -266,7 +266,7 @@ getcodec(PyObject *self, PyObject *encoding)
"encoding name must be a string.");
return NULL;
}
- enc = PyUnicode_AsString(encoding);
+ enc = _PyUnicode_AsString(encoding);
if (enc == NULL)
return NULL;
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index e65a9a4fb7..dbd5314e0a 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -95,7 +95,7 @@ call_error_callback(PyObject *errors, PyObject *exc)
const char *str;
assert(PyUnicode_Check(errors));
- str = PyUnicode_AsString(errors);
+ str = _PyUnicode_AsString(errors);
if (str == NULL)
return NULL;
cb = PyCodec_LookupError(str);
@@ -148,7 +148,7 @@ codecctx_errors_set(MultibyteStatefulCodecContext *self, PyObject *value,
return -1;
}
- str = PyUnicode_AsString(value);
+ str = _PyUnicode_AsString(value);
if (str == NULL)
return -1;
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 4dd4fe314d..702b6b984b 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -1219,7 +1219,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
assert(object && format && timetuple);
assert(PyUnicode_Check(format));
/* Convert the input format to a C string and size */
- pin = PyUnicode_AsStringAndSize(format, &flen);
+ pin = _PyUnicode_AsStringAndSize(format, &flen);
if (!pin)
return NULL;
@@ -1312,7 +1312,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
}
assert(Zreplacement != NULL);
assert(PyUnicode_Check(Zreplacement));
- ptoappend = PyUnicode_AsStringAndSize(Zreplacement,
+ ptoappend = _PyUnicode_AsStringAndSize(Zreplacement,
&ntoappend);
ntoappend = Py_SIZE(Zreplacement);
}
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index 039f7941eb..ca442e5e5f 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -113,7 +113,7 @@ grp_getgrnam(PyObject *self, PyObject *pyo_name)
py_str_name = PyObject_Str(pyo_name);
if (!py_str_name)
return NULL;
- name = PyUnicode_AsString(py_str_name);
+ name = _PyUnicode_AsString(py_str_name);
if ((p = getgrnam(name)) == NULL) {
PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name);
diff --git a/Modules/operator.c b/Modules/operator.c
index d31b178363..1398fcabb2 100644
--- a/Modules/operator.c
+++ b/Modules/operator.c
@@ -449,7 +449,7 @@ dotted_getattr(PyObject *obj, PyObject *attr)
return NULL;
}
- s = PyUnicode_AsString(attr);
+ s = _PyUnicode_AsString(attr);
Py_INCREF(obj);
for (;;) {
PyObject *newobj, *str;
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index 8f66144e66..5828c3f56d 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -809,7 +809,7 @@ oss_getattro(oss_audio_t *self, PyObject *nameobj)
PyObject * rval = NULL;
if (PyUnicode_Check(nameobj))
- name = PyUnicode_AsString(nameobj);
+ name = _PyUnicode_AsString(nameobj);
if (strcmp(name, "closed") == 0) {
rval = (self->fd == -1) ? Py_True : Py_False;
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 405681655c..2a61eec7be 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -718,7 +718,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
Py_DECREF(o);
}
}
- temp_str = PyUnicode_AsStringAndSize(temp, &len);
+ temp_str = _PyUnicode_AsStringAndSize(temp, &len);
strn = (char *)PyObject_MALLOC(len + 1);
if (strn != NULL)
(void) memcpy(strn, temp_str, len + 1);
@@ -807,7 +807,7 @@ build_node_tree(PyObject *tuple)
if (res && encoding) {
Py_ssize_t len;
const char *temp;
- temp = PyUnicode_AsStringAndSize(encoding, &len);
+ temp = _PyUnicode_AsStringAndSize(encoding, &len);
res->n_str = (char *)PyObject_MALLOC(len + 1);
if (res->n_str != NULL && temp != NULL)
(void) memcpy(res->n_str, temp, len + 1);
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4cdaf253e5..3b79d05a61 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5566,7 +5566,7 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table,
"configuration names must be strings or integers");
return 0;
}
- confname = PyUnicode_AsString(arg);
+ confname = _PyUnicode_AsString(arg);
if (confname == NULL)
return 0;
while (lo < hi) {
@@ -5897,7 +5897,7 @@ posix_confstr(PyObject *self, PyObject *args)
if ((unsigned int)len >= sizeof(buffer)) {
result = PyUnicode_FromStringAndSize(NULL, len-1);
if (result != NULL)
- confstr(name, PyUnicode_AsString(result), len);
+ confstr(name, _PyUnicode_AsString(result), len);
}
else
result = PyUnicode_FromStringAndSize(buffer, len-1);
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index e85f3924c7..df375898c4 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1338,7 +1338,7 @@ xmlparse_getattro(xmlparseobject *self, PyObject *nameobj)
int handlernum = -1;
if (PyUnicode_Check(nameobj))
- name = PyUnicode_AsString(nameobj);
+ name = _PyUnicode_AsString(nameobj);
handlernum = handlername2int(name);
diff --git a/Modules/readline.c b/Modules/readline.c
index 98da33b1c4..837194208f 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -724,7 +724,7 @@ on_completion(const char *text, int state)
result = NULL;
}
else {
- char *s = PyUnicode_AsString(r);
+ char *s = _PyUnicode_AsString(r);
if (s == NULL)
goto error;
result = strdup(s);
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index b948132d1a..de802ae1b0 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -3744,7 +3744,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args)
PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", value);
pptr = pbuf;
} else if (PyUnicode_Check(pobj)) {
- pptr = PyUnicode_AsString(pobj);
+ pptr = _PyUnicode_AsString(pobj);
} else if (PyBytes_Check(pobj)) {
pptr = PyBytes_AsString(pobj);
} else if (pobj == Py_None) {
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index 6c78679429..c6a3b36e26 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -72,7 +72,7 @@ syslog_openlog(PyObject * self, PyObject * args)
S_ident_o = new_S_ident_o;
Py_INCREF(S_ident_o);
- ident = PyUnicode_AsString(S_ident_o);
+ ident = _PyUnicode_AsString(S_ident_o);
if (ident == NULL)
return NULL;
openlog(ident, logopt, facility);
@@ -97,7 +97,7 @@ syslog_syslog(PyObject * self, PyObject * args)
return NULL;
}
- message = PyUnicode_AsString(message_object);
+ message = _PyUnicode_AsString(message_object);
if (message == NULL)
return NULL;
Py_BEGIN_ALLOW_THREADS;
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index d2817fb92e..c32b53d463 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -509,7 +509,7 @@ time_strftime(PyObject *self, PyObject *args)
}
/* Convert the unicode string to an ascii one */
- fmt = PyUnicode_AsString(format);
+ fmt = _PyUnicode_AsString(format);
fmtlen = strlen(fmt);
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 023d1d4efb..336859d59c 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -180,9 +180,9 @@ zipimporter_repr(ZipImporter *self)
char *prefix = "";
if (self->archive != NULL && PyUnicode_Check(self->archive))
- archive = PyUnicode_AsString(self->archive);
+ archive = _PyUnicode_AsString(self->archive);
if (self->prefix != NULL && PyUnicode_Check(self->prefix))
- prefix = PyUnicode_AsString(self->prefix);
+ prefix = _PyUnicode_AsString(self->prefix);
if (prefix != NULL && *prefix)
return PyUnicode_FromFormat("<zipimporter object \"%.300s%c%.150s\">",
archive, SEP, prefix);
@@ -248,7 +248,7 @@ get_module_info(ZipImporter *self, char *fullname)
subname = get_subname(fullname);
- len = make_filename(PyUnicode_AsString(self->prefix), subname, path);
+ len = make_filename(_PyUnicode_AsString(self->prefix), subname, path);
if (len < 0)
return MI_ERROR;
@@ -321,12 +321,12 @@ zipimporter_load_module(PyObject *obj, PyObject *args)
/* add __path__ to the module *before* the code gets
executed */
PyObject *pkgpath, *fullpath;
- char *prefix = PyUnicode_AsString(self->prefix);
+ char *prefix = _PyUnicode_AsString(self->prefix);
char *subname = get_subname(fullname);
int err;
fullpath = PyUnicode_FromFormat("%s%c%s%s",
- PyUnicode_AsString(self->archive),
+ _PyUnicode_AsString(self->archive),
SEP,
prefix ? prefix : "",
subname);
@@ -404,7 +404,7 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
}
path = buf;
#endif
- archive_str = PyUnicode_AsStringAndSize(self->archive, &len);
+ archive_str = _PyUnicode_AsStringAndSize(self->archive, &len);
if ((size_t)len < strlen(path) &&
strncmp(path, archive_str, len) == 0 &&
path[len] == SEP) {
@@ -453,7 +453,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
}
subname = get_subname(fullname);
- len = make_filename(PyUnicode_AsString(self->prefix), subname, path);
+ len = make_filename(_PyUnicode_AsString(self->prefix), subname, path);
if (len < 0)
return NULL;
@@ -466,7 +466,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
toc_entry = PyDict_GetItemString(self->files, path);
if (toc_entry != NULL) {
- PyObject *bytes = get_data(PyUnicode_AsString(self->archive), toc_entry);
+ PyObject *bytes = get_data(_PyUnicode_AsString(self->archive), toc_entry);
PyObject *res = PyUnicode_FromString(PyByteArray_AsString(bytes));
Py_XDECREF(bytes);
return res;
@@ -1053,7 +1053,7 @@ get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,
{
PyObject *data, *code;
char *modpath;
- char *archive = PyUnicode_AsString(self->archive);
+ char *archive = _PyUnicode_AsString(self->archive);
if (archive == NULL)
return NULL;
@@ -1062,7 +1062,7 @@ get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,
if (data == NULL)
return NULL;
- modpath = PyUnicode_AsString(PyTuple_GetItem(toc_entry, 0));
+ modpath = _PyUnicode_AsString(PyTuple_GetItem(toc_entry, 0));
if (isbytecode) {
code = unmarshal_code(modpath, data, mtime);
@@ -1087,7 +1087,7 @@ get_module_code(ZipImporter *self, char *fullname,
subname = get_subname(fullname);
- len = make_filename(PyUnicode_AsString(self->prefix), subname, path);
+ len = make_filename(_PyUnicode_AsString(self->prefix), subname, path);
if (len < 0)
return NULL;
@@ -1097,7 +1097,7 @@ get_module_code(ZipImporter *self, char *fullname,
strcpy(path + len, zso->suffix);
if (Py_VerboseFlag > 1)
PySys_WriteStderr("# trying %s%c%s\n",
- PyUnicode_AsString(self->archive),
+ _PyUnicode_AsString(self->archive),
SEP, path);
toc_entry = PyDict_GetItemString(self->files, path);
if (toc_entry != NULL) {
@@ -1119,7 +1119,7 @@ get_module_code(ZipImporter *self, char *fullname,
continue;
}
if (code != NULL && p_modpath != NULL)
- *p_modpath = PyUnicode_AsString(
+ *p_modpath = _PyUnicode_AsString(
PyTuple_GetItem(toc_entry, 0));
return code;
}
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index eeae0ff589..7c1469c1a9 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3230,7 +3230,7 @@ _PyBytes_FormatLong(PyObject *val, int flags, int prec, int type,
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 cb8f3e430a..01a637aa6d 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -296,7 +296,7 @@ code_repr(PyCodeObject *co)
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 02a55c1254..52869cbb67 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -943,7 +943,7 @@ SyntaxError_str(PySyntaxErrorObject *self)
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 efad21250c..4478168a46 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1229,7 +1229,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
* 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 @@ float_getformat(PyTypeObject *v, PyObject* arg)
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 fddb120bc7..594e524a81 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -297,7 +297,7 @@ func_set_code(PyFunctionObject *op, PyObject *value)
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 228ffeeae1..ae01651297 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -187,7 +187,7 @@ PyModule_GetName(PyObject *m)
PyErr_SetString(PyExc_SystemError, "nameless module");
return NULL;
}
- return PyUnicode_AsString(nameobj);
+ return _PyUnicode_AsString(nameobj);
}
const char *
@@ -207,7 +207,7 @@ PyModule_GetFilename(PyObject *m)
PyErr_SetString(PyExc_SystemError, "module filename missing");
return NULL;
}
- return PyUnicode_AsString(fileobj);
+ return _PyUnicode_AsString(fileobj);
}
PyModuleDef*
@@ -252,7 +252,7 @@ _PyModule_Clear(PyObject *m)
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 @@ _PyModule_Clear(PyObject *m)
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 ff16994e65..79f8288a4f 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -856,7 +856,7 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
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 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
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 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
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 771f47efea..10541662b6 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -2390,7 +2390,7 @@ test_c_api(PySetObject *so)
/* 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 56e885c8c3..091370c9ad 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -270,7 +270,7 @@ structseq_repr(PyStructSequence *obj)
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 9306552a6a..616164e1ce 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -258,7 +258,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
}
Py_DECREF(tmp);
- tp_name = PyUnicode_AsString(value);
+ tp_name = _PyUnicode_AsString(value);
if (tp_name == NULL)
return -1;
@@ -1255,7 +1255,7 @@ check_duplicates(PyObject *list)
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 @@ consistent method resolution\norder (MRO) for bases");
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_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
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 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
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 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
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 5925f8077f..5bf0fa2885 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1452,7 +1452,7 @@ PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
}
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 @@ PyUnicode_AsStringAndSize(PyObject *unicode, Py_ssize_t *psize)
}
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 6ceed73de9..83e63fc4f5 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -167,7 +167,7 @@ weakref_repr(PyWeakReference *self)
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>",
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 487405f20e..e2da3e5b6b 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -391,7 +391,7 @@ fp_readl(char *s, int size, struct tok_state *tok)
}
if (PyUnicode_CheckExact(bufobj))
{
- buf = PyUnicode_AsStringAndSize(bufobj, &buflen);
+ buf = _PyUnicode_AsStringAndSize(bufobj, &buflen);
if (buf == NULL) {
goto error;
}
diff --git a/Python/_warnings.c b/Python/_warnings.c
index cb81b07925..fd3f629e85 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -132,7 +132,7 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
return NULL;
if (good_msg && is_subclass && good_mod && (ln == 0 || lineno == ln))
- return PyUnicode_AsString(action);
+ return _PyUnicode_AsString(action);
}
m = PyImport_ImportModule(MODULE_NAME);
@@ -144,7 +144,7 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
return NULL;
action = PyDict_GetItemString(d, DEFAULT_ACTION_NAME);
if (action != NULL)
- return PyUnicode_AsString(action);
+ return _PyUnicode_AsString(action);
PyErr_SetString(PyExc_ValueError,
MODULE_NAME "." DEFAULT_ACTION_NAME " not found");
@@ -186,7 +186,7 @@ normalize_module(PyObject *filename)
else if (rc == 0)
return PyUnicode_FromString("<unknown>");
- mod_str = PyUnicode_AsString(filename);
+ mod_str = _PyUnicode_AsString(filename);
if (mod_str == NULL)
return NULL;
len = PyUnicode_GetSize(filename);
@@ -257,7 +257,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
/* Print " source_line\n" */
if (sourceline) {
- char *source_line_str = PyUnicode_AsString(sourceline);
+ char *source_line_str = _PyUnicode_AsString(sourceline);
while (*source_line_str == ' ' || *source_line_str == '\t' ||
*source_line_str == '\014')
source_line_str++;
@@ -266,7 +266,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
PyFile_WriteString("\n", f_stderr);
}
else
- _Py_DisplaySourceLine(f_stderr, PyUnicode_AsString(filename),
+ _Py_DisplaySourceLine(f_stderr, _PyUnicode_AsString(filename),
lineno, 2);
PyErr_Clear();
}
@@ -367,7 +367,7 @@ warn_explicit(PyObject *category, PyObject *message,
const char *err_str = "???";
if (to_str != NULL)
- err_str = PyUnicode_AsString(to_str);
+ err_str = _PyUnicode_AsString(to_str);
PyErr_Format(PyExc_RuntimeError,
"Unrecognized action (%s) in warnings.filters:\n %s",
action, err_str);
@@ -388,7 +388,7 @@ warn_explicit(PyObject *category, PyObject *message,
else {
const char *msg = "functions overriding warnings.showwarning() "
"must support the 'line' argument";
- const char *text_char = PyUnicode_AsString(text);
+ const char *text_char = _PyUnicode_AsString(text);
if (strcmp(msg, text_char) == 0) {
/* Prevent infinite recursion by using built-in implementation
@@ -503,7 +503,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
*filename = PyDict_GetItemString(globals, "__file__");
if (*filename != NULL) {
Py_ssize_t len = PyUnicode_GetSize(*filename);
- const char *file_str = PyUnicode_AsString(*filename);
+ const char *file_str = _PyUnicode_AsString(*filename);
if (file_str == NULL || (len < 0 && PyErr_Occurred()))
goto handle_error;
@@ -523,7 +523,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
Py_INCREF(*filename);
}
else {
- const char *module_str = PyUnicode_AsString(*module);
+ const char *module_str = _PyUnicode_AsString(*module);
if (module_str && strcmp(module_str, "__main__") == 0) {
PyObject *argv = PySys_GetObject("argv");
if (argv != NULL && PyList_Size(argv) > 0) {
diff --git a/Python/ast.c b/Python/ast.c
index 9adb5a2273..46bfd4e803 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1324,7 +1324,7 @@ ast_for_atom(struct compiling *c, const node *n)
if (errstr) {
char *s = "";
char buf[128];
- s = PyUnicode_AsString(errstr);
+ s = _PyUnicode_AsString(errstr);
PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s);
ast_error(n, buf);
} else {
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 27a3d8c005..ae7ceec696 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1606,7 +1606,7 @@ builtin_input(PyObject *self, PyObject *args)
Py_DECREF(stdin_encoding);
return NULL;
}
- prompt = PyUnicode_AsString(po);
+ prompt = _PyUnicode_AsString(po);
if (prompt == NULL) {
Py_DECREF(stdin_encoding);
Py_DECREF(po);
@@ -1639,7 +1639,7 @@ builtin_input(PyObject *self, PyObject *args)
else {
result = PyUnicode_Decode
(s, len-1,
- PyUnicode_AsString(stdin_encoding),
+ _PyUnicode_AsString(stdin_encoding),
NULL);
}
}
diff --git a/Python/ceval.c b/Python/ceval.c
index af7a67a6d7..40ce0389cd 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -859,7 +859,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL;
#endif
#if defined(Py_DEBUG) || defined(LLTRACE)
- filename = PyUnicode_AsString(co->co_filename);
+ filename = _PyUnicode_AsString(co->co_filename);
#endif
why = WHY_NOT;
@@ -3291,7 +3291,7 @@ PyEval_GetFuncName(PyObject *func)
if (PyMethod_Check(func))
return PyEval_GetFuncName(PyMethod_GET_FUNCTION(func));
else if (PyFunction_Check(func))
- return PyUnicode_AsString(((PyFunctionObject*)func)->func_name);
+ return _PyUnicode_AsString(((PyFunctionObject*)func)->func_name);
else if (PyCFunction_Check(func))
return ((PyCFunctionObject*)func)->m_ml->ml_name;
else
@@ -3527,7 +3527,7 @@ update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack,
"for keyword argument '%.200s'",
PyEval_GetFuncName(func),
PyEval_GetFuncDesc(func),
- PyUnicode_AsString(key));
+ _PyUnicode_AsString(key));
Py_DECREF(key);
Py_DECREF(value);
Py_DECREF(kwdict);
@@ -3874,7 +3874,7 @@ format_exc_check_arg(PyObject *exc, const char *format_str, PyObject *obj)
if (!obj)
return;
- obj_str = PyUnicode_AsString(obj);
+ obj_str = _PyUnicode_AsString(obj);
if (!obj_str)
return;
diff --git a/Python/compile.c b/Python/compile.c
index 942ca1f525..4600589a5e 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1300,7 +1300,7 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, int args)
PyObject_REPR(name),
PyBytes_AS_STRING(c->u->u_name),
reftype, arg,
- PyUnicode_AsString(co->co_name),
+ _PyUnicode_AsString(co->co_name),
PyObject_REPR(co->co_freevars));
Py_FatalError("compiler_make_closure()");
}
diff --git a/Python/errors.c b/Python/errors.c
index 5ee6255a2a..9c9eb2f2b2 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -709,7 +709,7 @@ PyErr_WriteUnraisable(PyObject *obj)
if (moduleName == NULL)
PyFile_WriteString("<unknown>", f);
else {
- char* modstr = PyUnicode_AsString(moduleName);
+ char* modstr = _PyUnicode_AsString(moduleName);
if (modstr &&
strcmp(modstr, "builtins") != 0)
{
diff --git a/Python/future.c b/Python/future.c
index a5bee0c9c6..e775384ec2 100644
--- a/Python/future.c
+++ b/Python/future.c
@@ -20,7 +20,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
names = s->v.ImportFrom.names;
for (i = 0; i < asdl_seq_LEN(names); i++) {
alias_ty name = (alias_ty)asdl_seq_GET(names, i);
- const char *feature = PyUnicode_AsString(name->name);
+ const char *feature = _PyUnicode_AsString(name->name);
if (!feature)
return 0;
if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) {
diff --git a/Python/getargs.c b/Python/getargs.c
index ccd1817568..36a6261cc3 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -1537,7 +1537,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
"keywords must be strings");
return cleanreturn(0, freelist);
}
- ks = PyUnicode_AsString(key);
+ ks = _PyUnicode_AsString(key);
for (i = 0; i < len; i++) {
if (!strcmp(ks, kwlist[i])) {
match = 1;
diff --git a/Python/import.c b/Python/import.c
index a43bd43a57..bedec1ecfa 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -470,7 +470,7 @@ PyImport_Cleanup(void)
if (value->ob_refcnt != 1)
continue;
if (PyUnicode_Check(key) && PyModule_Check(value)) {
- name = PyUnicode_AsString(key);
+ name = _PyUnicode_AsString(key);
if (strcmp(name, "builtins") == 0)
continue;
if (strcmp(name, "sys") == 0)
@@ -489,7 +489,7 @@ PyImport_Cleanup(void)
pos = 0;
while (PyDict_Next(modules, &pos, &key, &value)) {
if (PyUnicode_Check(key) && PyModule_Check(value)) {
- name = PyUnicode_AsString(key);
+ name = _PyUnicode_AsString(key);
if (strcmp(name, "builtins") == 0)
continue;
if (strcmp(name, "sys") == 0)
@@ -1296,7 +1296,7 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
if (path != NULL && PyUnicode_Check(path)) {
/* The only type of submodule allowed inside a "frozen"
package are other frozen modules or packages. */
- char *p = PyUnicode_AsString(path);
+ char *p = _PyUnicode_AsString(path);
if (strlen(p) + 1 + strlen(name) >= (size_t)buflen) {
PyErr_SetString(PyExc_ImportError,
"full frozen module name too long");
@@ -2197,7 +2197,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
"__package__ set to non-string");
return NULL;
}
- pkgname_str = PyUnicode_AsStringAndSize(pkgname, &len);
+ pkgname_str = _PyUnicode_AsStringAndSize(pkgname, &len);
if (len == 0) {
if (level > 0) {
PyErr_SetString(PyExc_ValueError,
@@ -2225,7 +2225,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
Py_ssize_t len;
int error;
- modname_str = PyUnicode_AsStringAndSize(modname, &len);
+ modname_str = _PyUnicode_AsStringAndSize(modname, &len);
if (len > MAXPATHLEN) {
PyErr_SetString(PyExc_ValueError,
"Module name too long");
@@ -2240,7 +2240,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
}
} else {
/* Normal module, so work out the package name if any */
- char *start = PyUnicode_AsString(modname);
+ char *start = _PyUnicode_AsString(modname);
char *lastdot = strrchr(start, '.');
size_t len;
int error;
@@ -2635,7 +2635,7 @@ PyImport_ReloadModule(PyObject *m)
if (parent == NULL) {
PyErr_Format(PyExc_ImportError,
"reload(): parent %.200s not in sys.modules",
- PyUnicode_AsString(parentname));
+ _PyUnicode_AsString(parentname));
Py_DECREF(parentname);
imp_modules_reloading_clear();
return NULL;
diff --git a/Python/peephole.c b/Python/peephole.c
index 30789e4c4e..b9b26fc0a7 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -407,7 +407,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
case LOAD_NAME:
case LOAD_GLOBAL:
j = GETARG(codestr, i);
- name = PyUnicode_AsString(PyTuple_GET_ITEM(names, j));
+ name = _PyUnicode_AsString(PyTuple_GET_ITEM(names, j));
h = load_global(codestr, i, name, consts);
if (h < 0)
goto exitUnchanged;
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 2ab1d464ef..a1777bd5b2 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -803,7 +803,7 @@ initstdio(void)
encoding_attr = PyObject_GetAttrString(std, "encoding");
if (encoding_attr != NULL) {
const char * encoding;
- encoding = PyUnicode_AsString(encoding_attr);
+ encoding = _PyUnicode_AsString(encoding_attr);
if (encoding != NULL) {
_PyCodec_Lookup(encoding);
}
@@ -909,7 +909,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
oenc = PyObject_GetAttrString(v, "encoding");
if (!oenc)
return -1;
- enc = PyUnicode_AsString(oenc);
+ enc = _PyUnicode_AsString(oenc);
}
v = PySys_GetObject("ps1");
if (v != NULL) {
@@ -917,7 +917,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
if (v == NULL)
PyErr_Clear();
else if (PyUnicode_Check(v))
- ps1 = PyUnicode_AsString(v);
+ ps1 = _PyUnicode_AsString(v);
}
w = PySys_GetObject("ps2");
if (w != NULL) {
@@ -925,7 +925,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
if (w == NULL)
PyErr_Clear();
else if (PyUnicode_Check(w))
- ps2 = PyUnicode_AsString(w);
+ ps2 = _PyUnicode_AsString(w);
}
arena = PyArena_New();
if (arena == NULL) {
@@ -1101,7 +1101,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
goto finally;
if (v == Py_None)
*filename = NULL;
- else if (! (*filename = PyUnicode_AsString(v)))
+ else if (! (*filename = _PyUnicode_AsString(v)))
goto finally;
Py_DECREF(v);
@@ -1134,7 +1134,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
if (v == Py_None)
*text = NULL;
else if (!PyUnicode_Check(v) ||
- !(*text = PyUnicode_AsString(v)))
+ !(*text = _PyUnicode_AsString(v)))
goto finally;
Py_DECREF(v);
return 1;
@@ -1357,7 +1357,7 @@ print_exception(PyObject *f, PyObject *value)
err = PyFile_WriteString("<unknown>", f);
}
else {
- char* modstr = PyUnicode_AsString(moduleName);
+ char* modstr = _PyUnicode_AsString(moduleName);
if (modstr && strcmp(modstr, "builtins"))
{
err = PyFile_WriteString(modstr, f);
@@ -1806,7 +1806,7 @@ err_input(perrdetail *err)
if (value != NULL) {
u = PyObject_Str(value);
if (u != NULL) {
- msg = PyUnicode_AsString(u);
+ msg = _PyUnicode_AsString(u);
}
}
if (msg == NULL)
diff --git a/Python/structmember.c b/Python/structmember.c
index 6c1e932963..9f08a6baf8 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -247,7 +247,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
PyErr_BadArgument();
return -1;
}
- string = PyUnicode_AsStringAndSize(v, &len);
+ string = _PyUnicode_AsStringAndSize(v, &len);
if (len != 1) {
PyErr_BadArgument();
return -1;
diff --git a/Python/symtable.c b/Python/symtable.c
index 0c11ee1aab..92432abad6 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1142,7 +1142,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
asdl_seq *seq = s->v.Global.names;
for (i = 0; i < asdl_seq_LEN(seq); i++) {
identifier name = (identifier)asdl_seq_GET(seq, i);
- char *c_name = PyUnicode_AsString(name);
+ char *c_name = _PyUnicode_AsString(name);
long cur = symtable_lookup(st, name);
if (cur < 0)
return 0;
@@ -1169,7 +1169,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
asdl_seq *seq = s->v.Nonlocal.names;
for (i = 0; i < asdl_seq_LEN(seq); i++) {
identifier name = (identifier)asdl_seq_GET(seq, i);
- char *c_name = PyUnicode_AsString(name);
+ char *c_name = _PyUnicode_AsString(name);
long cur = symtable_lookup(st, name);
if (cur < 0)
return 0;
diff --git a/Python/traceback.c b/Python/traceback.c
index d569a18de3..dffce35b44 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -257,10 +257,10 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
while (tb != NULL && err == 0) {
if (depth <= limit) {
err = tb_displayline(f,
- PyUnicode_AsString(
+ _PyUnicode_AsString(
tb->tb_frame->f_code->co_filename),
tb->tb_lineno,
- PyUnicode_AsString(tb->tb_frame->f_code->co_name));
+ _PyUnicode_AsString(tb->tb_frame->f_code->co_name));
}
depth--;
tb = tb->tb_next;