mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII(). Unrelated change to please the linter: remove an unused import in test_ctypes. Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
4109a9c6b3
commit
f49a07b531
17 changed files with 103 additions and 31 deletions
|
@ -979,7 +979,7 @@ contextvar_tp_repr(PyObject *op)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (PyUnicodeWriter_WriteUTF8(writer, "<ContextVar name=", 17) < 0) {
|
||||
if (PyUnicodeWriter_WriteASCII(writer, "<ContextVar name=", 17) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (PyUnicodeWriter_WriteRepr(writer, self->var_name) < 0) {
|
||||
|
@ -987,7 +987,7 @@ contextvar_tp_repr(PyObject *op)
|
|||
}
|
||||
|
||||
if (self->var_default != NULL) {
|
||||
if (PyUnicodeWriter_WriteUTF8(writer, " default=", 9) < 0) {
|
||||
if (PyUnicodeWriter_WriteASCII(writer, " default=", 9) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (PyUnicodeWriter_WriteRepr(writer, self->var_default) < 0) {
|
||||
|
@ -1182,15 +1182,15 @@ token_tp_repr(PyObject *op)
|
|||
if (writer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (PyUnicodeWriter_WriteUTF8(writer, "<Token", 6) < 0) {
|
||||
if (PyUnicodeWriter_WriteASCII(writer, "<Token", 6) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (self->tok_used) {
|
||||
if (PyUnicodeWriter_WriteUTF8(writer, " used", 5) < 0) {
|
||||
if (PyUnicodeWriter_WriteASCII(writer, " used", 5) < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (PyUnicodeWriter_WriteUTF8(writer, " var=", 5) < 0) {
|
||||
if (PyUnicodeWriter_WriteASCII(writer, " var=", 5) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (PyUnicodeWriter_WriteRepr(writer, (PyObject *)self->tok_var) < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue