]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 20 Nov 2016 07:13:07 +0000 (09:13 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 20 Nov 2016 07:13:07 +0000 (09:13 +0200)
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.

31 files changed:
Modules/_ctypes/_ctypes.c
Modules/_ctypes/stgdict.c
Modules/_datetimemodule.c
Modules/_io/stringio.c
Modules/_io/textio.c
Modules/_pickle.c
Modules/_sqlite/connection.c
Modules/_sqlite/cursor.c
Modules/_sqlite/row.c
Modules/_sqlite/statement.c
Modules/cjkcodecs/cjkcodecs.h
Modules/cjkcodecs/multibytecodec.c
Modules/parsermodule.c
Modules/posixmodule.c
Modules/socketmodule.c
Modules/syslogmodule.c
Modules/timemodule.c
Objects/floatobject.c
Objects/moduleobject.c
Objects/object.c
Objects/setobject.c
Objects/structseq.c
Objects/typeobject.c
Parser/tokenizer.c
Python/bltinmodule.c
Python/ceval.c
Python/future.c
Python/pylifecycle.c
Python/pythonrun.c
Python/structmember.c
Python/sysmodule.c

index 65c950e4c9cb6cc7e92707b9cb5deb941daf1910..4807e4f51dd4bfff70bfc215753bf0147e420ab8 100644 (file)
@@ -1723,7 +1723,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_AsUTF8(stgd->proto)[0]) {
         case 'z': /* c_char_p */
         case 'Z': /* c_wchar_p */
             parg = PyCArgObject_new();
@@ -1835,7 +1835,7 @@ PyCSimpleType_paramfunc(CDataObject *self)
 
     dict = PyObject_stgdict((PyObject *)self);
     assert(dict); /* Cannot be NULL for CDataObject instances */
-    fmt = _PyUnicode_AsString(dict->proto);
+    fmt = PyUnicode_AsUTF8(dict->proto);
     assert(fmt);
 
     fd = _ctypes_get_fielddesc(fmt);
@@ -2059,7 +2059,7 @@ PyCSimpleType_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_AsUTF8(dict->proto);
     assert(fmt);
 
     fd = _ctypes_get_fielddesc(fmt);
@@ -3128,7 +3128,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_AsUTF8(dict->proto)[0]))) {
         return 1;
     }
 
@@ -3218,7 +3218,7 @@ _get_name(PyObject *obj, const char **pname)
         return *pname ? 1 : 0;
     }
     if (PyUnicode_Check(obj)) {
-        *pname = _PyUnicode_AsString(obj);
+        *pname = PyUnicode_AsUTF8(obj);
         return *pname ? 1 : 0;
     }
     PyErr_SetString(PyExc_TypeError,
@@ -5233,7 +5233,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_AsUTF8(dict->proto)[0]))) {
             /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
             return 1;
         }
index 6c0fda901a69125ea82947600ce451997576a035..716d1e9e8eb5df76d10078afff02072e9ecd71db 100644 (file)
@@ -489,7 +489,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
 
         if (isStruct && !isPacked) {
             char *fieldfmt = dict->format ? dict->format : "B";
-            char *fieldname = _PyUnicode_AsString(name);
+            char *fieldname = PyUnicode_AsUTF8(name);
             char *ptr;
             Py_ssize_t len;
             char *buf;
index 5ddf6504c579df312fb0c28b8c431128e2e33d7c..d0ddcc2daa3f34984c6c1c816d110505185d60d9 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_AsUTF8AndSize(format, &flen);
     if (!pin)
         return NULL;
 
@@ -1287,7 +1287,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
             }
             assert(Zreplacement != NULL);
             assert(PyUnicode_Check(Zreplacement));
-            ptoappend = _PyUnicode_AsStringAndSize(Zreplacement,
+            ptoappend = PyUnicode_AsUTF8AndSize(Zreplacement,
                                                   &ntoappend);
             if (ptoappend == NULL)
                 goto Done;
index ecf6dc196346229a99775bfc7259cd7f27997fe7..8542efd9726a7aab74efa3ba1998de232713184e 100644 (file)
@@ -708,7 +708,7 @@ _io_StringIO___init___impl(stringio *self, PyObject *value,
                          Py_TYPE(newline_obj)->tp_name);
             return -1;
         }
-        newline = _PyUnicode_AsString(newline_obj);
+        newline = PyUnicode_AsUTF8(newline_obj);
         if (newline == NULL)
             return -1;
     }
index 2f55eb0595b6e2c33eb459f9ea3830564ff5ac21..1c7200b0aea6ef904a0a47a797a3ac5a5135a5d5 100644 (file)
@@ -921,7 +921,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
             Py_CLEAR(self->encoding);
     }
     if (self->encoding != NULL) {
-        encoding = _PyUnicode_AsString(self->encoding);
+        encoding = PyUnicode_AsUTF8(self->encoding);
         if (encoding == NULL)
             goto error;
     }
@@ -964,7 +964,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
     }
     self->writetranslate = (newline == NULL || newline[0] != '\0');
     if (!self->readuniversal && self->readnl) {
-        self->writenl = _PyUnicode_AsString(self->readnl);
+        self->writenl = PyUnicode_AsUTF8(self->readnl);
         if (self->writenl == NULL)
             goto error;
         if (!strcmp(self->writenl, "\n"))
index 54b1856f8b12c93eae033c9406cdfd9f1ced78b5..79113e0a93bb770ad747dabb5e188285529b5ca7 100644 (file)
@@ -1951,7 +1951,7 @@ save_long(PicklerObject *self, PyObject *obj)
         if (repr == NULL)
             goto error;
 
-        string = _PyUnicode_AsStringAndSize(repr, &size);
+        string = PyUnicode_AsUTF8AndSize(repr, &size);
         if (string == NULL)
             goto error;
 
index f37de42975b1331adc4cfda45eedcf27516d0c25..1c6aa54c224d36eff47aec3d91ec0e0875d7c1ca 100644 (file)
@@ -505,7 +505,7 @@ _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)) {
-        const char *str = _PyUnicode_AsString(py_val);
+        const char *str = PyUnicode_AsUTF8(py_val);
         if (str == NULL)
             return -1;
         sqlite3_result_text(context, str, -1, SQLITE_TRANSIENT);
@@ -1527,7 +1527,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
         }
     }
 
-    uppercase_name_str = _PyUnicode_AsString(uppercase_name);
+    uppercase_name_str = PyUnicode_AsUTF8(uppercase_name);
     if (!uppercase_name_str)
         goto finally;
 
index c7169f6d6ed5443ef46523c15ac1a50dc3e0cc0b..39f7a6508c2aef1a013ba1270945d2ab079abb9b 100644 (file)
@@ -465,7 +465,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
         pysqlite_statement_reset(self->statement);
     }
 
-    operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
+    operation_cstr = PyUnicode_AsUTF8AndSize(operation, &operation_len);
     if (operation_cstr == NULL)
         goto error;
 
@@ -689,7 +689,7 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
     self->reset = 0;
 
     if (PyUnicode_Check(script_obj)) {
-        script_cstr = _PyUnicode_AsString(script_obj);
+        script_cstr = PyUnicode_AsUTF8(script_obj);
         if (!script_cstr) {
             return NULL;
         }
index 07584e30e5ff23e7e5941b69b5735bb65bad0678..53342f3444c097bc9b1801596c672a0385ec8fa1 100644 (file)
@@ -98,7 +98,7 @@ 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_AsUTF8(idx);
         if (key == NULL)
             return NULL;
 
@@ -108,7 +108,7 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
             PyObject *obj;
             obj = PyTuple_GET_ITEM(self->description, i);
             obj = PyTuple_GET_ITEM(obj, 0);
-            compare_key = _PyUnicode_AsString(obj);
+            compare_key = PyUnicode_AsUTF8(obj);
             if (!compare_key) {
                 return NULL;
             }
index 7b980135ed076243d2bbca379a9a59b5eef913fa..0df661b9c7ad315a0f2a76dfd939b8a0738867b3 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_AsUTF8AndSize(sql, &sql_cstr_len);
     if (sql_cstr == NULL) {
         rc = PYSQLITE_SQL_WRONG_TYPE;
         return rc;
@@ -152,7 +152,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_AsStringAndSize(parameter, &buflen);
+            string = PyUnicode_AsUTF8AndSize(parameter, &buflen);
             if (string == NULL)
                 return -1;
             if (buflen > INT_MAX) {
@@ -325,7 +325,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_AsUTF8AndSize(self->sql, &sql_len);
     if (sql_cstr == NULL) {
         rc = PYSQLITE_SQL_WRONG_TYPE;
         return rc;
index b72a3f00283b3879193e54d501c7c1f7a9549b65..2ae28ecbe207546723b6390bcada9eb4e5bc9428 100644 (file)
@@ -267,7 +267,7 @@ getcodec(PyObject *self, PyObject *encoding)
                         "encoding name must be a string.");
         return NULL;
     }
-    enc = _PyUnicode_AsString(encoding);
+    enc = PyUnicode_AsUTF8(encoding);
     if (enc == NULL)
         return NULL;
 
index f5c842154b9aff2d94418b67a75c84c790244c3f..d1da189ddd3bef7e60b2246807f45727b8ae5443 100644 (file)
@@ -85,7 +85,7 @@ call_error_callback(PyObject *errors, PyObject *exc)
     const char *str;
 
     assert(PyUnicode_Check(errors));
-    str = _PyUnicode_AsString(errors);
+    str = PyUnicode_AsUTF8(errors);
     if (str == NULL)
         return NULL;
     cb = PyCodec_LookupError(str);
@@ -138,7 +138,7 @@ codecctx_errors_set(MultibyteStatefulCodecContext *self, PyObject *value,
         return -1;
     }
 
-    str = _PyUnicode_AsString(value);
+    str = PyUnicode_AsUTF8(value);
     if (str == NULL)
         return -1;
 
index 82770a52ff4a196f92c1509761ab6ea14a546f02..b2566951d06de1b7abb9c055753f09a3f1fc1eff 100644 (file)
@@ -912,7 +912,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
                     Py_DECREF(o);
                 }
             }
-            temp_str = _PyUnicode_AsStringAndSize(temp, &len);
+            temp_str = PyUnicode_AsUTF8AndSize(temp, &len);
             if (temp_str == NULL) {
                 Py_DECREF(temp);
                 Py_XDECREF(elem);
@@ -1013,7 +1013,7 @@ build_node_tree(PyObject *tuple)
             if (res && encoding) {
                 Py_ssize_t len;
                 const char *temp;
-                temp = _PyUnicode_AsStringAndSize(encoding, &len);
+                temp = PyUnicode_AsUTF8AndSize(encoding, &len);
                 if (temp == NULL) {
                     Py_DECREF(res);
                     Py_DECREF(encoding);
index acef3c31e8b5dd356da6675ffb1ed83d0bd8880b..ae251025cb55ca362f1081d2927398969a6d29ef 100644 (file)
@@ -9325,7 +9325,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_AsUTF8(arg);
         if (confname == NULL)
             return 0;
         while (lo < hi) {
index c9a38cc24c998508b2ef86fa3382a15fb351ff9d..4c1d8f00343e43f716744cf53dd109d94b95cd4b 100644 (file)
@@ -5989,7 +5989,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
         PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", value);
         pptr = pbuf;
     } else if (PyUnicode_Check(pobj)) {
-        pptr = _PyUnicode_AsString(pobj);
+        pptr = PyUnicode_AsUTF8(pobj);
         if (pptr == NULL)
             goto err;
     } else if (PyBytes_Check(pobj)) {
index f2d44ff5e6b17c438bf25593c1ec4de0031bd2cd..7afca58d0ec8c986763f6ba3980e1358a2df644b 100644 (file)
@@ -139,7 +139,7 @@ syslog_openlog(PyObject * self, PyObject * args, PyObject *kwds)
      * If NULL, just let openlog figure it out (probably using C argv[0]).
      */
     if (S_ident_o) {
-        ident = _PyUnicode_AsString(S_ident_o);
+        ident = PyUnicode_AsUTF8(S_ident_o);
         if (ident == NULL)
             return NULL;
     }
@@ -167,7 +167,7 @@ syslog_syslog(PyObject * self, PyObject * args)
             return NULL;
     }
 
-    message = _PyUnicode_AsString(message_object);
+    message = PyUnicode_AsUTF8(message_object);
     if (message == NULL)
         return NULL;
 
index f0708338e843ddd814bc5f1e81488ee53547c417..db0ab5805c50d9e7514eba464877850afc41df49 100644 (file)
@@ -441,7 +441,7 @@ gettmarg(PyObject *args, struct tm *p)
     if (Py_TYPE(args) == &StructTimeType) {
         PyObject *item;
         item = PyTuple_GET_ITEM(args, 9);
-        p->tm_zone = item == Py_None ? NULL : _PyUnicode_AsString(item);
+        p->tm_zone = item == Py_None ? NULL : PyUnicode_AsUTF8(item);
         item = PyTuple_GET_ITEM(args, 10);
         p->tm_gmtoff = item == Py_None ? 0 : PyLong_AsLong(item);
         if (PyErr_Occurred())
index 0f37618215ca5faa212a736fd838cb4f5dcd6db1..80bf71efd21a4e424d8da48a54f969f777f6f99d 100644 (file)
@@ -1274,7 +1274,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_AsUTF8AndSize(arg, &length);
     if (s == NULL)
         return NULL;
     s_end = s + length;
@@ -1628,7 +1628,7 @@ float_getformat(PyTypeObject *v, PyObject* arg)
                          Py_TYPE(arg)->tp_name);
         return NULL;
     }
-    s = _PyUnicode_AsString(arg);
+    s = PyUnicode_AsUTF8(arg);
     if (s == NULL)
         return NULL;
     if (strcmp(s, "double") == 0) {
index b6a2d6fe9c40b0b450db2696b624e280274f8ac3..79be51a806b707233aed5d98ddef675feb38d05b 100644 (file)
@@ -483,7 +483,7 @@ PyModule_GetName(PyObject *m)
     if (name == NULL)
         return NULL;
     Py_DECREF(name);   /* module dict has still a reference */
-    return _PyUnicode_AsString(name);
+    return PyUnicode_AsUTF8(name);
 }
 
 PyObject*
@@ -516,7 +516,7 @@ PyModule_GetFilename(PyObject *m)
     fileobj = PyModule_GetFilenameObject(m);
     if (fileobj == NULL)
         return NULL;
-    utf8 = _PyUnicode_AsString(fileobj);
+    utf8 = PyUnicode_AsUTF8(fileobj);
     Py_DECREF(fileobj);   /* module dict has still a reference */
     return utf8;
 }
@@ -569,7 +569,7 @@ _PyModule_ClearDict(PyObject *d)
             if (PyUnicode_READ_CHAR(key, 0) == '_' &&
                 PyUnicode_READ_CHAR(key, 1) != '_') {
                 if (Py_VerboseFlag > 1) {
-                    const char *s = _PyUnicode_AsString(key);
+                    const char *s = PyUnicode_AsUTF8(key);
                     if (s != NULL)
                         PySys_WriteStderr("#   clear[1] %s\n", s);
                     else
@@ -589,7 +589,7 @@ _PyModule_ClearDict(PyObject *d)
                 !_PyUnicode_EqualToASCIIString(key, "__builtins__"))
             {
                 if (Py_VerboseFlag > 1) {
-                    const char *s = _PyUnicode_AsString(key);
+                    const char *s = PyUnicode_AsUTF8(key);
                     if (s != NULL)
                         PySys_WriteStderr("#   clear[2] %s\n", s);
                     else
index 5c639b2c9c985912630ef2058a7dfab7383e6cdd..d88ae3b94f3e7d49928a4dfe5d3ba4adfa3c902b 100644 (file)
@@ -890,7 +890,7 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
     if (tp->tp_getattro != NULL)
         return (*tp->tp_getattro)(v, name);
     if (tp->tp_getattr != NULL) {
-        char *name_str = _PyUnicode_AsString(name);
+        char *name_str = PyUnicode_AsUTF8(name);
         if (name_str == NULL)
             return NULL;
         return (*tp->tp_getattr)(v, name_str);
@@ -934,7 +934,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
         return err;
     }
     if (tp->tp_setattr != NULL) {
-        char *name_str = _PyUnicode_AsString(name);
+        char *name_str = PyUnicode_AsUTF8(name);
         if (name_str == NULL)
             return -1;
         err = (*tp->tp_setattr)(v, name_str, value);
index 5846045376d64396bca2ba1bd4033f90a4d05e13..fdb9d3600d9fad28c724c21e0ca5f9628074eaab 100644 (file)
@@ -2466,7 +2466,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_AsUTF8(x);
         assert(s && (s[0] == 'a' || s[0] == 'b' || s[0] == 'c'));
         count++;
     }
index e315cbace508b446c4f2febb7ae0df8367c6db99..5489aef6d087475abf3b1ad129d0cd6622b5b0aa 100644 (file)
@@ -194,7 +194,7 @@ structseq_repr(PyStructSequence *obj)
         repr = PyObject_Repr(val);
         if (repr == NULL)
             return NULL;
-        crepr = _PyUnicode_AsString(repr);
+        crepr = PyUnicode_AsUTF8(repr);
         if (crepr == NULL) {
             Py_DECREF(repr);
             return NULL;
index dc9a80a34fba78300f3bc3c053d9ad1fcf732cd9..606e08e449e0d8528cf736a718c3db63af71f15c 100644 (file)
@@ -1626,7 +1626,7 @@ consistent method resolution\norder (MRO) for bases");
         PyObject *name = class_name(k);
         char *name_str;
         if (name != NULL) {
-            name_str = _PyUnicode_AsString(name);
+            name_str = PyUnicode_AsUTF8(name);
             if (name_str == NULL)
                 name_str = "?";
         } else
@@ -2575,7 +2575,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
             char *doc_str;
             char *tp_doc;
 
-            doc_str = _PyUnicode_AsString(doc);
+            doc_str = PyUnicode_AsUTF8(doc);
             if (doc_str == NULL)
                 goto error;
             /* Silently truncate the docstring if it contains null bytes. */
@@ -2623,7 +2623,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
     slotoffset = base->tp_basicsize;
     if (et->ht_slots != NULL) {
         for (i = 0; i < nslots; i++, mp++) {
-            mp->name = _PyUnicode_AsString(
+            mp->name = PyUnicode_AsUTF8(
                 PyTuple_GET_ITEM(et->ht_slots, i));
             if (mp->name == NULL)
                 goto error;
index 831729379680cc2cd94e7f0f0a2af85853d38386..0fa3aebc0f8d515c2302d8abda760da09101291f 100644 (file)
@@ -446,7 +446,7 @@ fp_readl(char *s, int size, struct tok_state *tok)
     }
     if (PyUnicode_CheckExact(bufobj))
     {
-        buf = _PyUnicode_AsStringAndSize(bufobj, &buflen);
+        buf = PyUnicode_AsUTF8AndSize(bufobj, &buflen);
         if (buf == NULL) {
             goto error;
         }
index cee013f57b2d34f424750a2b6d0b95dfb65fb45e..a49cb9d103ef25cd733f18f215eb5489adc660c1 100644 (file)
@@ -1903,8 +1903,8 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
             /* stdin is a text stream, so it must have an
                encoding. */
             goto _readline_errors;
-        stdin_encoding_str = _PyUnicode_AsString(stdin_encoding);
-        stdin_errors_str = _PyUnicode_AsString(stdin_errors);
+        stdin_encoding_str = PyUnicode_AsUTF8(stdin_encoding);
+        stdin_errors_str = PyUnicode_AsUTF8(stdin_errors);
         if (!stdin_encoding_str || !stdin_errors_str)
             goto _readline_errors;
         tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
@@ -1920,8 +1920,8 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
             stdout_errors = _PyObject_GetAttrId(fout, &PyId_errors);
             if (!stdout_encoding || !stdout_errors)
                 goto _readline_errors;
-            stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
-            stdout_errors_str = _PyUnicode_AsString(stdout_errors);
+            stdout_encoding_str = PyUnicode_AsUTF8(stdout_encoding);
+            stdout_errors_str = PyUnicode_AsUTF8(stdout_errors);
             if (!stdout_encoding_str || !stdout_errors_str)
                 goto _readline_errors;
             stringpo = PyObject_Str(prompt);
index 6bdc9983e3f0dba88128a80aa03009942111250a..a9d7c2f6d3d030eb2c211408379f02f4c6993492 100644 (file)
@@ -4712,7 +4712,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_AsUTF8(((PyFunctionObject*)func)->func_name);
     else if (PyCFunction_Check(func))
         return ((PyCFunctionObject*)func)->m_ml->ml_name;
     else
@@ -5286,7 +5286,7 @@ format_exc_check_arg(PyObject *exc, const char *format_str, PyObject *obj)
     if (!obj)
         return;
 
-    obj_str = _PyUnicode_AsString(obj);
+    obj_str = PyUnicode_AsUTF8(obj);
     if (!obj_str)
         return;
 
index d94b23d4d23b8d03e654601a6ed3fe1bf31ef73d..9c1f43032a1363a968780f8f4d3c356464498625 100644 (file)
@@ -21,7 +21,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, PyObject *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_AsUTF8(name->name);
         if (!feature)
             return 0;
         if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) {
index 71f23dd1505768e44f4ee7b3f5aff34574c9e89b..a4f7f823bc695dd82e431cd6573389eae6d89dc4 100644 (file)
@@ -205,7 +205,7 @@ get_codec_name(const char *encoding)
     if (!name)
         goto error;
 
-    name_utf8 = _PyUnicode_AsString(name);
+    name_utf8 = PyUnicode_AsUTF8(name);
     if (name_utf8 == NULL)
         goto error;
     name_str = _PyMem_RawStrdup(name_utf8);
@@ -1285,7 +1285,7 @@ initstdio(void)
     encoding_attr = PyObject_GetAttrString(std, "encoding");
     if (encoding_attr != NULL) {
         const char * std_encoding;
-        std_encoding = _PyUnicode_AsString(encoding_attr);
+        std_encoding = PyUnicode_AsUTF8(encoding_attr);
         if (std_encoding != NULL) {
             PyObject *codec_info = _PyCodec_Lookup(std_encoding);
             Py_XDECREF(codec_info);
index 5b1b78672b7e39bcefdf8dd6b041f06fcc80f87c..c881f901ab5d861c689e4174d775fb01b0c6977b 100644 (file)
@@ -171,7 +171,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
         if (v && v != Py_None) {
             oenc = _PyObject_GetAttrId(v, &PyId_encoding);
             if (oenc)
-                enc = _PyUnicode_AsString(oenc);
+                enc = PyUnicode_AsUTF8(oenc);
             if (!enc)
                 PyErr_Clear();
         }
@@ -182,7 +182,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
         if (v == NULL)
             PyErr_Clear();
         else if (PyUnicode_Check(v)) {
-            ps1 = _PyUnicode_AsString(v);
+            ps1 = PyUnicode_AsUTF8(v);
             if (ps1 == NULL) {
                 PyErr_Clear();
                 ps1 = "";
@@ -195,7 +195,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
         if (w == NULL)
             PyErr_Clear();
         else if (PyUnicode_Check(w)) {
-            ps2 = _PyUnicode_AsString(w);
+            ps2 = PyUnicode_AsUTF8(w);
             if (ps2 == NULL) {
                 PyErr_Clear();
                 ps2 = "";
@@ -514,7 +514,7 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj)
     char *text;
     char *nl;
 
-    text = _PyUnicode_AsString(text_obj);
+    text = PyUnicode_AsUTF8(text_obj);
     if (text == NULL)
         return;
 
index 86d4c66ca7476be8126e54330f540ac6c782d6cb..be2737d405e12ccef1d0aabd3e390b6d67491a03 100644 (file)
@@ -252,7 +252,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
         char *string;
         Py_ssize_t len;
 
-        string = _PyUnicode_AsStringAndSize(v, &len);
+        string = PyUnicode_AsUTF8AndSize(v, &len);
         if (string == NULL || len != 1) {
             PyErr_BadArgument();
             return -1;
index e348b3873e7e07287a9f6562a60392fa237947ec..52034ff7fb5ddf6ce2db83e2e713dc77153b5c7a 100644 (file)
@@ -114,7 +114,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o)
     stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding);
     if (stdout_encoding == NULL)
         goto error;
-    stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
+    stdout_encoding_str = PyUnicode_AsUTF8(stdout_encoding);
     if (stdout_encoding_str == NULL)
         goto error;
 
@@ -2411,7 +2411,7 @@ sys_format(_Py_Identifier *key, FILE *fp, const char *format, va_list va)
     if (message != NULL) {
         if (sys_pyfile_write_unicode(message, file) != 0) {
             PyErr_Clear();
-            utf8 = _PyUnicode_AsString(message);
+            utf8 = PyUnicode_AsUTF8(message);
             if (utf8 != NULL)
                 fputs(utf8, fp);
         }