[Python-checkins] cpython (3.6): Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize

serhiy.storchaka python-checkins at python.org
Sun Nov 20 03:17:22 EST 2016


https://hg.python.org/cpython/rev/39f0e0cf49fd
changeset: 105208:39f0e0cf49fd
branch: 3.6
parent: 105206:0bb8ab158042
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Nov 20 09:13:07 2016 +0200
summary:
 Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
files:
 Modules/_ctypes/_ctypes.c | 12 ++++++------
 Modules/_ctypes/stgdict.c | 2 +-
 Modules/_datetimemodule.c | 4 ++--
 Modules/_io/stringio.c | 2 +-
 Modules/_io/textio.c | 4 ++--
 Modules/_pickle.c | 2 +-
 Modules/_sqlite/connection.c | 4 ++--
 Modules/_sqlite/cursor.c | 4 ++--
 Modules/_sqlite/row.c | 4 ++--
 Modules/_sqlite/statement.c | 6 +++---
 Modules/cjkcodecs/cjkcodecs.h | 2 +-
 Modules/cjkcodecs/multibytecodec.c | 4 ++--
 Modules/parsermodule.c | 4 ++--
 Modules/posixmodule.c | 2 +-
 Modules/socketmodule.c | 2 +-
 Modules/syslogmodule.c | 4 ++--
 Modules/timemodule.c | 2 +-
 Objects/floatobject.c | 4 ++--
 Objects/moduleobject.c | 8 ++++----
 Objects/object.c | 4 ++--
 Objects/setobject.c | 2 +-
 Objects/structseq.c | 2 +-
 Objects/typeobject.c | 6 +++---
 Parser/tokenizer.c | 2 +-
 Python/bltinmodule.c | 8 ++++----
 Python/ceval.c | 4 ++--
 Python/future.c | 2 +-
 Python/pylifecycle.c | 4 ++--
 Python/pythonrun.c | 8 ++++----
 Python/structmember.c | 2 +-
 Python/sysmodule.c | 4 ++--
 31 files changed, 62 insertions(+), 62 deletions(-)
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1723,7 +1723,7 @@
 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 @@
 
 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 @@
 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 @@
 /* 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 @@
 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 @@
 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;
 }
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -489,7 +489,7 @@
 
 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;
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1219,7 +1219,7 @@
 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 @@
 }
 assert(Zreplacement != NULL);
 assert(PyUnicode_Check(Zreplacement));
- ptoappend = _PyUnicode_AsStringAndSize(Zreplacement,
+ ptoappend = PyUnicode_AsUTF8AndSize(Zreplacement,
 &ntoappend);
 if (ptoappend == NULL)
 goto Done;
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c
--- a/Modules/_io/stringio.c
+++ b/Modules/_io/stringio.c
@@ -708,7 +708,7 @@
 Py_TYPE(newline_obj)->tp_name);
 return -1;
 }
- newline = _PyUnicode_AsString(newline_obj);
+ newline = PyUnicode_AsUTF8(newline_obj);
 if (newline == NULL)
 return -1;
 }
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -921,7 +921,7 @@
 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 @@
 }
 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"))
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1951,7 +1951,7 @@
 if (repr == NULL)
 goto error;
 
- string = _PyUnicode_AsStringAndSize(repr, &size);
+ string = PyUnicode_AsUTF8AndSize(repr, &size);
 if (string == NULL)
 goto error;
 
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -505,7 +505,7 @@
 } 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 @@
 }
 }
 
- uppercase_name_str = _PyUnicode_AsString(uppercase_name);
+ uppercase_name_str = PyUnicode_AsUTF8(uppercase_name);
 if (!uppercase_name_str)
 goto finally;
 
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -465,7 +465,7 @@
 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 @@
 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;
 }
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -98,7 +98,7 @@
 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 *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;
 }
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -59,7 +59,7 @@
 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 @@
 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 @@
 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;
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -267,7 +267,7 @@
 "encoding name must be a string.");
 return NULL;
 }
- enc = _PyUnicode_AsString(encoding);
+ enc = PyUnicode_AsUTF8(encoding);
 if (enc == NULL)
 return NULL;
 
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -85,7 +85,7 @@
 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 @@
 return -1;
 }
 
- str = _PyUnicode_AsString(value);
+ str = PyUnicode_AsUTF8(value);
 if (str == NULL)
 return -1;
 
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -912,7 +912,7 @@
 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 @@
 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);
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -9325,7 +9325,7 @@
 "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) {
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -5989,7 +5989,7 @@
 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)) {
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -139,7 +139,7 @@
 * 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 @@
 return NULL;
 }
 
- message = _PyUnicode_AsString(message_object);
+ message = PyUnicode_AsUTF8(message_object);
 if (message == NULL)
 return NULL;
 
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -441,7 +441,7 @@
 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())
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1274,7 +1274,7 @@
 * 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 @@
 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) {
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -483,7 +483,7 @@
 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 @@
 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 @@
 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 @@
 !_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
diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -890,7 +890,7 @@
 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 @@
 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);
diff --git a/Objects/setobject.c b/Objects/setobject.c
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -2466,7 +2466,7 @@
 /* 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++;
 }
diff --git a/Objects/structseq.c b/Objects/structseq.c
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -194,7 +194,7 @@
 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;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1626,7 +1626,7 @@
 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 @@
 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 @@
 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;
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -446,7 +446,7 @@
 }
 if (PyUnicode_CheckExact(bufobj))
 {
- buf = _PyUnicode_AsStringAndSize(bufobj, &buflen);
+ buf = PyUnicode_AsUTF8AndSize(bufobj, &buflen);
 if (buf == NULL) {
 goto error;
 }
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1903,8 +1903,8 @@
 /* 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 @@
 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);
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4712,7 +4712,7 @@
 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 @@
 if (!obj)
 return;
 
- obj_str = _PyUnicode_AsString(obj);
+ obj_str = PyUnicode_AsUTF8(obj);
 if (!obj_str)
 return;
 
diff --git a/Python/future.c b/Python/future.c
--- a/Python/future.c
+++ b/Python/future.c
@@ -21,7 +21,7 @@
 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) {
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -205,7 +205,7 @@
 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 @@
 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);
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -171,7 +171,7 @@
 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 @@
 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 @@
 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 @@
 char *text;
 char *nl;
 
- text = _PyUnicode_AsString(text_obj);
+ text = PyUnicode_AsUTF8(text_obj);
 if (text == NULL)
 return;
 
diff --git a/Python/structmember.c b/Python/structmember.c
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -252,7 +252,7 @@
 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;
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -114,7 +114,7 @@
 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 @@
 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);
 }
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /