]> granicus.if.org Git - python/commitdiff
Rename PyUnicode_AsString -> _PyUnicode_AsString and
authorMarc-André Lemburg <mal@egenix.com>
Thu, 7 Aug 2008 18:54:33 +0000 (18:54 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Thu, 7 Aug 2008 18:54:33 +0000 (18:54 +0000)
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.

60 files changed:
Include/object.h
Include/unicodeobject.h
Misc/NEWS
Modules/_ctypes/_ctypes.c
Modules/_ctypes/callproc.c
Modules/_ctypes/stgdict.c
Modules/_elementtree.c
Modules/_gestalt.c
Modules/_hashopenssl.c
Modules/_lsprof.c
Modules/_pickle.c
Modules/_sqlite/connection.c
Modules/_sqlite/cursor.c
Modules/_sqlite/row.c
Modules/_sqlite/statement.c
Modules/_ssl.c
Modules/_struct.c
Modules/_testcapimodule.c
Modules/_tkinter.c
Modules/cjkcodecs/cjkcodecs.h
Modules/cjkcodecs/multibytecodec.c
Modules/datetimemodule.c
Modules/grpmodule.c
Modules/operator.c
Modules/ossaudiodev.c
Modules/parsermodule.c
Modules/posixmodule.c
Modules/pyexpat.c
Modules/readline.c
Modules/socketmodule.c
Modules/syslogmodule.c
Modules/timemodule.c
Modules/zipimport.c
Objects/bytesobject.c
Objects/codeobject.c
Objects/exceptions.c
Objects/floatobject.c
Objects/funcobject.c
Objects/moduleobject.c
Objects/object.c
Objects/setobject.c
Objects/structseq.c
Objects/typeobject.c
Objects/unicodeobject.c
Objects/weakrefobject.c
Parser/tokenizer.c
Python/_warnings.c
Python/ast.c
Python/bltinmodule.c
Python/ceval.c
Python/compile.c
Python/errors.c
Python/future.c
Python/getargs.c
Python/import.c
Python/peephole.c
Python/pythonrun.c
Python/structmember.c
Python/symtable.c
Python/traceback.c

index 07a4b2c89da58aa315dea2550f173425d84b7fa3..f5ec7d49a72291dc68e4b39d45a43afcf10cc93d 100644 (file)
@@ -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. */
index d5b657292a0f7fee3dc682b3b8a7eeb664d03553..c2360d35bfab34ec35f983c897a72334551285c1 100644 (file)
@@ -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.
 
index 3679a5b1c5b71dcc25e4e0210da04d495fde5c5d..1e22f70a414b5f645049ddfb63f251be139a406f 100644 (file)
--- 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
 -------
 
index 48fe7725082fffc1026bfa606d3c36cef95d59da..02a08a40c45709e547097bce00a5eca4db7554cf 100644 (file)
@@ -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;
                }
index d45278580fa897ca0bf58a2059fc255a749393f9..6dced06d656726110aced43e3204386d2a16ad2f 100644 (file)
@@ -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),
index 085b19f50897bda40e14f61e520972a86250cc01..aac073f9a1a5278c1d83f0566c2dac32feaf1295 100644 (file)
@@ -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);
index da223c4ee09f7ae1cf0456aa226849d65d6d604a..767c6eebff011a8147e126bc8e1faf0f3e512a4d 100644 (file)
@@ -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();
 
index 3a7279f824071cc64b760f057d47fe17e62d9b25..462a6d265e5ee3c5fcaf360f589dec1c3f9547e6 100644 (file)
@@ -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;
 }
index 8965f434dc9bc85759f72c2b01ab1ff1500c1ba4..bd04411113b8113c72d42a94ea3ebfe8dc335e88 100644 (file)
@@ -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);
 }
 
index 69ecaf101bc08d7bd851b20a2dcfb21456fd59fa..a6fd1f802c43789aa13c47fa36c71caa082d925a 100644 (file)
@@ -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);
index 98cb62e1ed0c80ad32a7b2be79b2e57270c4f685..0f5b06bea8d68ec339e38b9299d0eb241210c340 100644 (file)
@@ -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;
index 1e529187cb3eed31ee94adf1e196cfb4fe3ea741..7b931c0b9c7e750d09eabc96b2691dcecd9523a8 100644 (file)
@@ -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);
index 14dd002165d0aabbe402439faca705b5b4aee4eb..9ac25f5cc07d7571fe0ca108ada7e9ce5c24f154 100644 (file)
@@ -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;
         }
index 008f19e523ab72b586170ef9e187e485827e2e17..8778af0a96ddc8134e78c697f7d33190be0490b5 100644 (file)
@@ -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;
             }
index fb1eec7c0f04ec23b9cb86e3ec03ad11ba4b1a32..d2f3c1ea05d1c92006c15c5c34daa13179e33d9e 100644 (file)
@@ -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;
index 25b82b44d60868178957e2c9d523cfa49e009584..48318a8abca92c427ec0af24a0b8d6d65712b93c 100644 (file)
@@ -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 "
index a1e56bee63af10f007c785266debf788b320de5b..43be9ed0a54ad3dfd06a31ca01096f635cd9bf15 100644 (file)
@@ -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;
index 45494dd5c68dd27d09e5f2f685978b6c41561d4b..3ee3bf4d01f81592850f11bf65c0f77e3ae25bb6 100644 (file)
@@ -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;                              \
        }                                               \
index 4e36daccd3d4930e657e93ee0c60f6651e574888..3bbc7e4c39ad529bc2e9f01d75726318e6bc5537 100644 (file)
@@ -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)) {
index 89c644cd045faa7bad5e542c8095c40505684375..0530a33ab1b5489a015b28b59906f01a8ae070c6 100644 (file)
@@ -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;
 
index e65a9a4fb7b52a1f42d2a3cccd0363aebcaa3aef..dbd5314e0a720dfa2803e20b91e0212cb36ad152 100644 (file)
@@ -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;
 
index 4dd4fe314d4f3422fc48439f50c8c4313861f6b4..702b6b984bb4390f4b38769ae8b26494aeea3d87 100644 (file)
@@ -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);
                }
index 039f7941eb4a06b723481e4e3b40366c7b47dff7..ca442e5e5f9503c7a11a5fa7fdbaf37cf92b9594 100644 (file)
@@ -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);
index d31b1783633128a3bfd27883b8c0a1395c9b3b21..1398fcabb2cefb166c3232c034d44a9d64abde94 100644 (file)
@@ -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;
index 8f66144e66abd094ffec86fad6a7ee7e175d9baf..5828c3f56d11444079b55e51d9d6420665d627fc 100644 (file)
@@ -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;
index 405681655cf55727dcd025831dd0c226a1c27ede..2a61eec7bee8196bbe66115d1f31742747b74a54 100644 (file)
@@ -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);
index 4cdaf253e5c0f17ebb8d5877642c328a88ce2001..3b79d05a610d74840b3241ed703680e297d67be8 100644 (file)
@@ -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);
index e85f3924c70d7801c1cb875fac18e9a1ec93e382..df375898c419b5c351d839b047d7dbc518f8f102 100644 (file)
@@ -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);
 
index 98da33b1c48460a147712e3c5dbebf180c5211c6..837194208ff546a1b623fe2a187f4659ef45b1a7 100644 (file)
@@ -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);
index b948132d1a47e738ed272cee8383343b95ff8100..de802ae1b0cdf9ca0454c9f4a54b2503e101f822 100644 (file)
@@ -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) {
index 6c7867942993e865d945213ec0a548cc125c9cad..c6a3b36e269a01ff31538de890c2f861f1c969af 100644 (file)
@@ -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;
index d2817fb92ef53f141533c43a44464c4b90d35431..c32b53d4633b240ff85c15a67b8549df3fad7be7 100644 (file)
@@ -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);
 
index 023d1d4efb2a0ad2752ed45a5ef64dac23a45864..336859d59c44a50ce74f06d16cdbc3524d028d45 100644 (file)
@@ -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;
                }
index eeae0ff5893d77f54ea43bb6a0e848be03150af0..7c1469c1a9e706356ebd5afd93e25958d91a05c0 100644 (file)
@@ -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;
index cb8f3e430a8f6560842011a2c780d92fccafe940..01a637aa6d006f7cdb31949bee39350a082e81fa 100644 (file)
@@ -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);
index 02a55c12542cf1d796057df547b236a3969c3e76..52869cbb67773155ddf88b31f3cb40f9ec941d60 100644 (file)
@@ -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);
 
index efad21250c8dfb2f2750ed0e84d71fa3a5d2c3cc..4478168a462c01e1ef39ede1b34f986cb0901377 100644 (file)
@@ -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) {
index fddb120bc75d70d511685e4e1a07af14e9a3315a..594e524a81067bf638836399aca68aec11e0f476 100644 (file)
@@ -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;
        }
index 228ffeeae1f023a8e1fdf1a90afbc069780e8934..ae01651297a669b37615c8a9d6c3dda5e0263e5f 100644 (file)
@@ -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);
index ff16994e651d80d8eac7fb392c40819204318192..79f8288a4f5abdfd1414affd5c8e03c5a1a43b37 100644 (file)
@@ -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;
index 771f47efea0e1d1eeb1258bf578c491f31bbf10c..10541662b637a1596074a7ff8aa3f5cfadadafa8 100644 (file)
@@ -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++;
        }
index 56e885c8c323693d501974c26a67b67b50711841..091370c9ad5f455d2569179b1c7e56f55969c275 100644 (file)
@@ -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);
index 9306552a6adee1a1ebbd11fe1fed8fd4e1f2cff2..616164e1ce7475ca291918b8e4ceeca5f049a978 100644 (file)
@@ -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;
index 5925f8077f552fdceee7689f0f35e6dc4bd8a2cb..5bf0fa2885537642a601a9ac0006f811bcbe03e7 100644 (file)
@@ -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)
index 6ceed73de99ed76eae6ce9ae61cebab737fd8f4f..83e63fc4f5aa3ea8e3b6cdac8fbf1a4230ae8460 100644 (file)
@@ -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>",
index 487405f20ede90e0236b3efd747a2e669e0f9ad2..e2da3e5b6b0ba17d5882996696c7f5611b8609dd 100644 (file)
@@ -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;
                }
index cb81b07925204a37eef70b7e5a0e2a36b9ada7d8..fd3f629e85ffaa58f94a65c481842103cac79014 100644 (file)
@@ -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) {
index 9adb5a227380fb795fddfd73de6e7a9e276b1e3a..46bfd4e8034a81f8e9939433f9b2eb288861a1c3 100644 (file)
@@ -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 {
index 27a3d8c005e79fa96b58ea2594266cd2fd6388ff..ae7ceec69691709e64ec46e0a81f4b375446455e 100644 (file)
@@ -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);
                        }
                }
index af7a67a6d7a6d2f28039d6767126aacb0900488c..40ce0389cdea4dc34e5553f11f083311ae0161ec 100644 (file)
@@ -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;
 
index 942ca1f525f934c66de544498175ddf6678a8d1b..4600589a5e34bd94a72284669cd2f32b1c1aea38 100644 (file)
@@ -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()");
                }
index 5ee6255a2a042da0d96da1a7045cfd1d0d1f5b72..9c9eb2f2b21ffe6094a79bc734f08b9adcb1b1d1 100644 (file)
@@ -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)
                                {
index a5bee0c9c69b010551d75a5c9fb4babee7171388..e775384ec28968b73f079d4bd0d03b8933c043f0 100644 (file)
@@ -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) {
index ccd18175683939baafe44c101387a39db08331e0..36a6261cc3e509033755d04a84dc5ef4ef5812e9 100644 (file)
@@ -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;
index a43bd43a57a4d1101b1fb0c6087323492930a852..bedec1ecfa5efbc24555d4266d4c8311ba07f98b 100644 (file)
@@ -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;
index 30789e4c4e65ac1e55930c5426d9c9df3ea6c88e..b9b26fc0a70a5f8c1ac8e123da2483d0add4b40a 100644 (file)
@@ -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;
index 2ab1d464ef9d98223df631660e5a9f0ee0d37151..a1777bd5b2ed39a0f8b048e60e2707ee6a3a711e 100644 (file)
@@ -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)
index 6c1e9329637eb2a6e263e0efd24abe1a9a91a272..9f08a6baf8e857253d2e0c163585495efd925faf 100644 (file)
@@ -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;
index 0c11ee1aab31f22f339541f6eb866b04c1909778..92432abad62bf24505fe3799343df1228334b592 100644 (file)
@@ -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;
index d569a18de352153a1b1bacf177a7523f99a2ec75..dffce35b44530a57098482c2d0561674d6abdbba 100644 (file)
@@ -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;