mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
This commit is contained in:
parent
e20973926a
commit
06515833fe
31 changed files with 62 additions and 62 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue