bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)

https://bugs.python.org/issue46765
This commit is contained in:
Eric Snow 2022-02-22 17:23:51 -07:00 committed by GitHub
parent cff4d5c5d2
commit 1f455361ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 192 additions and 526 deletions

View file

@ -35,17 +35,26 @@ struct _Py_global_strings {
STRUCT_FOR_STR(anon_module, "<module>") STRUCT_FOR_STR(anon_module, "<module>")
STRUCT_FOR_STR(anon_setcomp, "<setcomp>") STRUCT_FOR_STR(anon_setcomp, "<setcomp>")
STRUCT_FOR_STR(anon_string, "<string>") STRUCT_FOR_STR(anon_string, "<string>")
STRUCT_FOR_STR(anon_unknown, "<unknown>")
STRUCT_FOR_STR(close_br, "}")
STRUCT_FOR_STR(comma_sep, ", ") STRUCT_FOR_STR(comma_sep, ", ")
STRUCT_FOR_STR(dbl_close_br, "}}")
STRUCT_FOR_STR(dbl_open_br, "{{")
STRUCT_FOR_STR(dbl_percent, "%%") STRUCT_FOR_STR(dbl_percent, "%%")
STRUCT_FOR_STR(dot, ".") STRUCT_FOR_STR(dot, ".")
STRUCT_FOR_STR(dot_locals, ".<locals>") STRUCT_FOR_STR(dot_locals, ".<locals>")
STRUCT_FOR_STR(empty, "") STRUCT_FOR_STR(empty, "")
STRUCT_FOR_STR(list_err, "list index out of range")
STRUCT_FOR_STR(newline, "\n")
STRUCT_FOR_STR(open_br, "{")
STRUCT_FOR_STR(percent, "%") STRUCT_FOR_STR(percent, "%")
} literals; } literals;
struct { struct {
STRUCT_FOR_ID(False)
STRUCT_FOR_ID(Py_Repr) STRUCT_FOR_ID(Py_Repr)
STRUCT_FOR_ID(TextIOWrapper) STRUCT_FOR_ID(TextIOWrapper)
STRUCT_FOR_ID(True)
STRUCT_FOR_ID(WarningMessage) STRUCT_FOR_ID(WarningMessage)
STRUCT_FOR_ID(_) STRUCT_FOR_ID(_)
STRUCT_FOR_ID(__IOBase_closed) STRUCT_FOR_ID(__IOBase_closed)
@ -194,7 +203,9 @@ struct _Py_global_strings {
STRUCT_FOR_ID(__weakref__) STRUCT_FOR_ID(__weakref__)
STRUCT_FOR_ID(__xor__) STRUCT_FOR_ID(__xor__)
STRUCT_FOR_ID(_abc_impl) STRUCT_FOR_ID(_abc_impl)
STRUCT_FOR_ID(_annotation)
STRUCT_FOR_ID(_blksize) STRUCT_FOR_ID(_blksize)
STRUCT_FOR_ID(_bootstrap)
STRUCT_FOR_ID(_dealloc_warn) STRUCT_FOR_ID(_dealloc_warn)
STRUCT_FOR_ID(_finalizing) STRUCT_FOR_ID(_finalizing)
STRUCT_FOR_ID(_find_and_load) STRUCT_FOR_ID(_find_and_load)
@ -216,23 +227,31 @@ struct _Py_global_strings {
STRUCT_FOR_ID(big) STRUCT_FOR_ID(big)
STRUCT_FOR_ID(buffer) STRUCT_FOR_ID(buffer)
STRUCT_FOR_ID(builtins) STRUCT_FOR_ID(builtins)
STRUCT_FOR_ID(c_call)
STRUCT_FOR_ID(c_exception)
STRUCT_FOR_ID(c_return)
STRUCT_FOR_ID(call)
STRUCT_FOR_ID(clear) STRUCT_FOR_ID(clear)
STRUCT_FOR_ID(close) STRUCT_FOR_ID(close)
STRUCT_FOR_ID(closed)
STRUCT_FOR_ID(code) STRUCT_FOR_ID(code)
STRUCT_FOR_ID(copy) STRUCT_FOR_ID(copy)
STRUCT_FOR_ID(copyreg) STRUCT_FOR_ID(copyreg)
STRUCT_FOR_ID(decode) STRUCT_FOR_ID(decode)
STRUCT_FOR_ID(default) STRUCT_FOR_ID(default)
STRUCT_FOR_ID(defaultaction) STRUCT_FOR_ID(defaultaction)
STRUCT_FOR_ID(dictcomp)
STRUCT_FOR_ID(difference_update) STRUCT_FOR_ID(difference_update)
STRUCT_FOR_ID(dispatch_table) STRUCT_FOR_ID(dispatch_table)
STRUCT_FOR_ID(displayhook) STRUCT_FOR_ID(displayhook)
STRUCT_FOR_ID(enable) STRUCT_FOR_ID(enable)
STRUCT_FOR_ID(encode)
STRUCT_FOR_ID(encoding) STRUCT_FOR_ID(encoding)
STRUCT_FOR_ID(end_lineno) STRUCT_FOR_ID(end_lineno)
STRUCT_FOR_ID(end_offset) STRUCT_FOR_ID(end_offset)
STRUCT_FOR_ID(errors) STRUCT_FOR_ID(errors)
STRUCT_FOR_ID(excepthook) STRUCT_FOR_ID(excepthook)
STRUCT_FOR_ID(exception)
STRUCT_FOR_ID(extend) STRUCT_FOR_ID(extend)
STRUCT_FOR_ID(filename) STRUCT_FOR_ID(filename)
STRUCT_FOR_ID(fileno) STRUCT_FOR_ID(fileno)
@ -240,22 +259,30 @@ struct _Py_global_strings {
STRUCT_FOR_ID(filters) STRUCT_FOR_ID(filters)
STRUCT_FOR_ID(find_class) STRUCT_FOR_ID(find_class)
STRUCT_FOR_ID(flush) STRUCT_FOR_ID(flush)
STRUCT_FOR_ID(genexpr)
STRUCT_FOR_ID(get) STRUCT_FOR_ID(get)
STRUCT_FOR_ID(get_source) STRUCT_FOR_ID(get_source)
STRUCT_FOR_ID(getattr) STRUCT_FOR_ID(getattr)
STRUCT_FOR_ID(getstate)
STRUCT_FOR_ID(ignore) STRUCT_FOR_ID(ignore)
STRUCT_FOR_ID(importlib) STRUCT_FOR_ID(importlib)
STRUCT_FOR_ID(inf)
STRUCT_FOR_ID(intersection) STRUCT_FOR_ID(intersection)
STRUCT_FOR_ID(isatty) STRUCT_FOR_ID(isatty)
STRUCT_FOR_ID(items) STRUCT_FOR_ID(items)
STRUCT_FOR_ID(iter) STRUCT_FOR_ID(iter)
STRUCT_FOR_ID(join)
STRUCT_FOR_ID(keys) STRUCT_FOR_ID(keys)
STRUCT_FOR_ID(lambda)
STRUCT_FOR_ID(last_traceback) STRUCT_FOR_ID(last_traceback)
STRUCT_FOR_ID(last_type) STRUCT_FOR_ID(last_type)
STRUCT_FOR_ID(last_value) STRUCT_FOR_ID(last_value)
STRUCT_FOR_ID(latin1) STRUCT_FOR_ID(latin1)
STRUCT_FOR_ID(line)
STRUCT_FOR_ID(lineno) STRUCT_FOR_ID(lineno)
STRUCT_FOR_ID(listcomp)
STRUCT_FOR_ID(little) STRUCT_FOR_ID(little)
STRUCT_FOR_ID(locale)
STRUCT_FOR_ID(match) STRUCT_FOR_ID(match)
STRUCT_FOR_ID(metaclass) STRUCT_FOR_ID(metaclass)
STRUCT_FOR_ID(mode) STRUCT_FOR_ID(mode)
@ -266,9 +293,11 @@ struct _Py_global_strings {
STRUCT_FOR_ID(n_sequence_fields) STRUCT_FOR_ID(n_sequence_fields)
STRUCT_FOR_ID(n_unnamed_fields) STRUCT_FOR_ID(n_unnamed_fields)
STRUCT_FOR_ID(name) STRUCT_FOR_ID(name)
STRUCT_FOR_ID(newlines)
STRUCT_FOR_ID(obj) STRUCT_FOR_ID(obj)
STRUCT_FOR_ID(offset) STRUCT_FOR_ID(offset)
STRUCT_FOR_ID(onceregistry) STRUCT_FOR_ID(onceregistry)
STRUCT_FOR_ID(opcode)
STRUCT_FOR_ID(open) STRUCT_FOR_ID(open)
STRUCT_FOR_ID(parent) STRUCT_FOR_ID(parent)
STRUCT_FOR_ID(partial) STRUCT_FOR_ID(partial)
@ -296,6 +325,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(seek) STRUCT_FOR_ID(seek)
STRUCT_FOR_ID(seekable) STRUCT_FOR_ID(seekable)
STRUCT_FOR_ID(send) STRUCT_FOR_ID(send)
STRUCT_FOR_ID(setcomp)
STRUCT_FOR_ID(setstate) STRUCT_FOR_ID(setstate)
STRUCT_FOR_ID(sort) STRUCT_FOR_ID(sort)
STRUCT_FOR_ID(stderr) STRUCT_FOR_ID(stderr)
@ -307,6 +337,8 @@ struct _Py_global_strings {
STRUCT_FOR_ID(text) STRUCT_FOR_ID(text)
STRUCT_FOR_ID(threading) STRUCT_FOR_ID(threading)
STRUCT_FOR_ID(throw) STRUCT_FOR_ID(throw)
STRUCT_FOR_ID(top)
STRUCT_FOR_ID(truncate)
STRUCT_FOR_ID(unraisablehook) STRUCT_FOR_ID(unraisablehook)
STRUCT_FOR_ID(values) STRUCT_FOR_ID(values)
STRUCT_FOR_ID(version) STRUCT_FOR_ID(version)

View file

@ -651,16 +651,25 @@ extern "C" {
INIT_STR(anon_module, "<module>"), \ INIT_STR(anon_module, "<module>"), \
INIT_STR(anon_setcomp, "<setcomp>"), \ INIT_STR(anon_setcomp, "<setcomp>"), \
INIT_STR(anon_string, "<string>"), \ INIT_STR(anon_string, "<string>"), \
INIT_STR(anon_unknown, "<unknown>"), \
INIT_STR(close_br, "}"), \
INIT_STR(comma_sep, ", "), \ INIT_STR(comma_sep, ", "), \
INIT_STR(dbl_close_br, "}}"), \
INIT_STR(dbl_open_br, "{{"), \
INIT_STR(dbl_percent, "%%"), \ INIT_STR(dbl_percent, "%%"), \
INIT_STR(dot, "."), \ INIT_STR(dot, "."), \
INIT_STR(dot_locals, ".<locals>"), \ INIT_STR(dot_locals, ".<locals>"), \
INIT_STR(empty, ""), \ INIT_STR(empty, ""), \
INIT_STR(list_err, "list index out of range"), \
INIT_STR(newline, "\n"), \
INIT_STR(open_br, "{"), \
INIT_STR(percent, "%"), \ INIT_STR(percent, "%"), \
}, \ }, \
.identifiers = { \ .identifiers = { \
INIT_ID(False), \
INIT_ID(Py_Repr), \ INIT_ID(Py_Repr), \
INIT_ID(TextIOWrapper), \ INIT_ID(TextIOWrapper), \
INIT_ID(True), \
INIT_ID(WarningMessage), \ INIT_ID(WarningMessage), \
INIT_ID(_), \ INIT_ID(_), \
INIT_ID(__IOBase_closed), \ INIT_ID(__IOBase_closed), \
@ -809,7 +818,9 @@ extern "C" {
INIT_ID(__weakref__), \ INIT_ID(__weakref__), \
INIT_ID(__xor__), \ INIT_ID(__xor__), \
INIT_ID(_abc_impl), \ INIT_ID(_abc_impl), \
INIT_ID(_annotation), \
INIT_ID(_blksize), \ INIT_ID(_blksize), \
INIT_ID(_bootstrap), \
INIT_ID(_dealloc_warn), \ INIT_ID(_dealloc_warn), \
INIT_ID(_finalizing), \ INIT_ID(_finalizing), \
INIT_ID(_find_and_load), \ INIT_ID(_find_and_load), \
@ -831,23 +842,31 @@ extern "C" {
INIT_ID(big), \ INIT_ID(big), \
INIT_ID(buffer), \ INIT_ID(buffer), \
INIT_ID(builtins), \ INIT_ID(builtins), \
INIT_ID(c_call), \
INIT_ID(c_exception), \
INIT_ID(c_return), \
INIT_ID(call), \
INIT_ID(clear), \ INIT_ID(clear), \
INIT_ID(close), \ INIT_ID(close), \
INIT_ID(closed), \
INIT_ID(code), \ INIT_ID(code), \
INIT_ID(copy), \ INIT_ID(copy), \
INIT_ID(copyreg), \ INIT_ID(copyreg), \
INIT_ID(decode), \ INIT_ID(decode), \
INIT_ID(default), \ INIT_ID(default), \
INIT_ID(defaultaction), \ INIT_ID(defaultaction), \
INIT_ID(dictcomp), \
INIT_ID(difference_update), \ INIT_ID(difference_update), \
INIT_ID(dispatch_table), \ INIT_ID(dispatch_table), \
INIT_ID(displayhook), \ INIT_ID(displayhook), \
INIT_ID(enable), \ INIT_ID(enable), \
INIT_ID(encode), \
INIT_ID(encoding), \ INIT_ID(encoding), \
INIT_ID(end_lineno), \ INIT_ID(end_lineno), \
INIT_ID(end_offset), \ INIT_ID(end_offset), \
INIT_ID(errors), \ INIT_ID(errors), \
INIT_ID(excepthook), \ INIT_ID(excepthook), \
INIT_ID(exception), \
INIT_ID(extend), \ INIT_ID(extend), \
INIT_ID(filename), \ INIT_ID(filename), \
INIT_ID(fileno), \ INIT_ID(fileno), \
@ -855,22 +874,30 @@ extern "C" {
INIT_ID(filters), \ INIT_ID(filters), \
INIT_ID(find_class), \ INIT_ID(find_class), \
INIT_ID(flush), \ INIT_ID(flush), \
INIT_ID(genexpr), \
INIT_ID(get), \ INIT_ID(get), \
INIT_ID(get_source), \ INIT_ID(get_source), \
INIT_ID(getattr), \ INIT_ID(getattr), \
INIT_ID(getstate), \
INIT_ID(ignore), \ INIT_ID(ignore), \
INIT_ID(importlib), \ INIT_ID(importlib), \
INIT_ID(inf), \
INIT_ID(intersection), \ INIT_ID(intersection), \
INIT_ID(isatty), \ INIT_ID(isatty), \
INIT_ID(items), \ INIT_ID(items), \
INIT_ID(iter), \ INIT_ID(iter), \
INIT_ID(join), \
INIT_ID(keys), \ INIT_ID(keys), \
INIT_ID(lambda), \
INIT_ID(last_traceback), \ INIT_ID(last_traceback), \
INIT_ID(last_type), \ INIT_ID(last_type), \
INIT_ID(last_value), \ INIT_ID(last_value), \
INIT_ID(latin1), \ INIT_ID(latin1), \
INIT_ID(line), \
INIT_ID(lineno), \ INIT_ID(lineno), \
INIT_ID(listcomp), \
INIT_ID(little), \ INIT_ID(little), \
INIT_ID(locale), \
INIT_ID(match), \ INIT_ID(match), \
INIT_ID(metaclass), \ INIT_ID(metaclass), \
INIT_ID(mode), \ INIT_ID(mode), \
@ -881,9 +908,11 @@ extern "C" {
INIT_ID(n_sequence_fields), \ INIT_ID(n_sequence_fields), \
INIT_ID(n_unnamed_fields), \ INIT_ID(n_unnamed_fields), \
INIT_ID(name), \ INIT_ID(name), \
INIT_ID(newlines), \
INIT_ID(obj), \ INIT_ID(obj), \
INIT_ID(offset), \ INIT_ID(offset), \
INIT_ID(onceregistry), \ INIT_ID(onceregistry), \
INIT_ID(opcode), \
INIT_ID(open), \ INIT_ID(open), \
INIT_ID(parent), \ INIT_ID(parent), \
INIT_ID(partial), \ INIT_ID(partial), \
@ -911,6 +940,7 @@ extern "C" {
INIT_ID(seek), \ INIT_ID(seek), \
INIT_ID(seekable), \ INIT_ID(seekable), \
INIT_ID(send), \ INIT_ID(send), \
INIT_ID(setcomp), \
INIT_ID(setstate), \ INIT_ID(setstate), \
INIT_ID(sort), \ INIT_ID(sort), \
INIT_ID(stderr), \ INIT_ID(stderr), \
@ -922,6 +952,8 @@ extern "C" {
INIT_ID(text), \ INIT_ID(text), \
INIT_ID(threading), \ INIT_ID(threading), \
INIT_ID(throw), \ INIT_ID(throw), \
INIT_ID(top), \
INIT_ID(truncate), \
INIT_ID(unraisablehook), \ INIT_ID(unraisablehook), \
INIT_ID(values), \ INIT_ID(values), \
INIT_ID(version), \ INIT_ID(version), \

View file

@ -128,8 +128,6 @@ extern struct symtable* _Py_SymtableStringObjectFlags(
int start, int start,
PyCompilerFlags *flags); PyCompilerFlags *flags);
extern void _PySymtable_Fini(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -24,38 +24,6 @@
#include <windows.h> #include <windows.h>
#endif #endif
/* Various interned strings */
PyObject *_PyIO_str_close = NULL;
PyObject *_PyIO_str_closed = NULL;
PyObject *_PyIO_str_decode = NULL;
PyObject *_PyIO_str_encode = NULL;
PyObject *_PyIO_str_fileno = NULL;
PyObject *_PyIO_str_flush = NULL;
PyObject *_PyIO_str_getstate = NULL;
PyObject *_PyIO_str_isatty = NULL;
PyObject *_PyIO_str_locale = NULL;
PyObject *_PyIO_str_newlines = NULL;
PyObject *_PyIO_str_nl = NULL;
PyObject *_PyIO_str_peek = NULL;
PyObject *_PyIO_str_read = NULL;
PyObject *_PyIO_str_read1 = NULL;
PyObject *_PyIO_str_readable = NULL;
PyObject *_PyIO_str_readall = NULL;
PyObject *_PyIO_str_readinto = NULL;
PyObject *_PyIO_str_readline = NULL;
PyObject *_PyIO_str_reset = NULL;
PyObject *_PyIO_str_seek = NULL;
PyObject *_PyIO_str_seekable = NULL;
PyObject *_PyIO_str_setstate = NULL;
PyObject *_PyIO_str_tell = NULL;
PyObject *_PyIO_str_truncate = NULL;
PyObject *_PyIO_str_writable = NULL;
PyObject *_PyIO_str_write = NULL;
PyObject *_PyIO_empty_str = NULL;
PyObject *_PyIO_empty_bytes = NULL;
PyDoc_STRVAR(module_doc, PyDoc_STRVAR(module_doc,
"The io module provides the Python interfaces to stream handling. The\n" "The io module provides the Python interfaces to stream handling. The\n"
"builtin open function is defined in this module.\n" "builtin open function is defined in this module.\n"
@ -511,8 +479,7 @@ _io_text_encoding_impl(PyObject *module, PyObject *encoding, int stacklevel)
return NULL; return NULL;
} }
} }
Py_INCREF(_PyIO_str_locale); return &_Py_ID(locale);
return _PyIO_str_locale;
} }
Py_INCREF(encoding); Py_INCREF(encoding);
return encoding; return encoding;
@ -699,41 +666,6 @@ _PyIO_Fini(void)
PyTypeObject *exc = static_types[i]; PyTypeObject *exc = static_types[i];
_PyStaticType_Dealloc(exc); _PyStaticType_Dealloc(exc);
} }
/* Interned strings */
#define CLEAR_INTERNED(name) \
Py_CLEAR(_PyIO_str_ ## name)
CLEAR_INTERNED(close);
CLEAR_INTERNED(closed);
CLEAR_INTERNED(decode);
CLEAR_INTERNED(encode);
CLEAR_INTERNED(fileno);
CLEAR_INTERNED(flush);
CLEAR_INTERNED(getstate);
CLEAR_INTERNED(isatty);
CLEAR_INTERNED(locale);
CLEAR_INTERNED(newlines);
CLEAR_INTERNED(peek);
CLEAR_INTERNED(read);
CLEAR_INTERNED(read1);
CLEAR_INTERNED(readable);
CLEAR_INTERNED(readall);
CLEAR_INTERNED(readinto);
CLEAR_INTERNED(readline);
CLEAR_INTERNED(reset);
CLEAR_INTERNED(seek);
CLEAR_INTERNED(seekable);
CLEAR_INTERNED(setstate);
CLEAR_INTERNED(tell);
CLEAR_INTERNED(truncate);
CLEAR_INTERNED(write);
CLEAR_INTERNED(writable);
#undef CLEAR_INTERNED
Py_CLEAR(_PyIO_str_nl);
Py_CLEAR(_PyIO_empty_str);
Py_CLEAR(_PyIO_empty_bytes);
} }
@ -797,50 +729,6 @@ PyInit__io(void)
} }
} }
/* Interned strings */
#define ADD_INTERNED(name) \
if (!_PyIO_str_ ## name && \
!(_PyIO_str_ ## name = PyUnicode_InternFromString(# name))) \
goto fail;
ADD_INTERNED(close)
ADD_INTERNED(closed)
ADD_INTERNED(decode)
ADD_INTERNED(encode)
ADD_INTERNED(fileno)
ADD_INTERNED(flush)
ADD_INTERNED(getstate)
ADD_INTERNED(isatty)
ADD_INTERNED(locale)
ADD_INTERNED(newlines)
ADD_INTERNED(peek)
ADD_INTERNED(read)
ADD_INTERNED(read1)
ADD_INTERNED(readable)
ADD_INTERNED(readall)
ADD_INTERNED(readinto)
ADD_INTERNED(readline)
ADD_INTERNED(reset)
ADD_INTERNED(seek)
ADD_INTERNED(seekable)
ADD_INTERNED(setstate)
ADD_INTERNED(tell)
ADD_INTERNED(truncate)
ADD_INTERNED(write)
ADD_INTERNED(writable)
#undef ADD_INTERNED
if (!_PyIO_str_nl &&
!(_PyIO_str_nl = PyUnicode_InternFromString("\n")))
goto fail;
if (!_PyIO_empty_str &&
!(_PyIO_empty_str = PyUnicode_FromStringAndSize(NULL, 0)))
goto fail;
if (!_PyIO_empty_bytes &&
!(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0)))
goto fail;
state->initialized = 1; state->initialized = 1;
return m; return m;

View file

@ -155,33 +155,4 @@ extern _PyIO_State *_PyIO_get_module_state(void);
extern char _PyIO_get_console_type(PyObject *); extern char _PyIO_get_console_type(PyObject *);
#endif #endif
extern PyObject *_PyIO_str_close;
extern PyObject *_PyIO_str_closed;
extern PyObject *_PyIO_str_decode;
extern PyObject *_PyIO_str_encode;
extern PyObject *_PyIO_str_fileno;
extern PyObject *_PyIO_str_flush;
extern PyObject *_PyIO_str_getstate;
extern PyObject *_PyIO_str_isatty;
extern PyObject *_PyIO_str_newlines;
extern PyObject *_PyIO_str_nl;
extern PyObject *_PyIO_str_peek;
extern PyObject *_PyIO_str_read;
extern PyObject *_PyIO_str_read1;
extern PyObject *_PyIO_str_readable;
extern PyObject *_PyIO_str_readall;
extern PyObject *_PyIO_str_readinto;
extern PyObject *_PyIO_str_readline;
extern PyObject *_PyIO_str_reset;
extern PyObject *_PyIO_str_seek;
extern PyObject *_PyIO_str_seekable;
extern PyObject *_PyIO_str_setstate;
extern PyObject *_PyIO_str_tell;
extern PyObject *_PyIO_str_truncate;
extern PyObject *_PyIO_str_writable;
extern PyObject *_PyIO_str_write;
extern PyObject *_PyIO_empty_str;
extern PyObject *_PyIO_empty_bytes;
extern Py_EXPORTED_SYMBOL PyTypeObject _PyBytesIOBuffer_Type; extern Py_EXPORTED_SYMBOL PyTypeObject _PyBytesIOBuffer_Type;

View file

@ -443,7 +443,7 @@ static PyObject *
buffered_simple_flush(buffered *self, PyObject *args) buffered_simple_flush(buffered *self, PyObject *args)
{ {
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_flush); return PyObject_CallMethodNoArgs(self->raw, &_Py_ID(flush));
} }
static int static int
@ -452,7 +452,7 @@ buffered_closed(buffered *self)
int closed; int closed;
PyObject *res; PyObject *res;
CHECK_INITIALIZED_INT(self) CHECK_INITIALIZED_INT(self)
res = PyObject_GetAttr(self->raw, _PyIO_str_closed); res = PyObject_GetAttr(self->raw, &_Py_ID(closed));
if (res == NULL) if (res == NULL)
return -1; return -1;
closed = PyObject_IsTrue(res); closed = PyObject_IsTrue(res);
@ -464,7 +464,7 @@ static PyObject *
buffered_closed_get(buffered *self, void *context) buffered_closed_get(buffered *self, void *context)
{ {
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
return PyObject_GetAttr(self->raw, _PyIO_str_closed); return PyObject_GetAttr(self->raw, &_Py_ID(closed));
} }
static PyObject * static PyObject *
@ -495,7 +495,7 @@ buffered_close(buffered *self, PyObject *args)
} }
/* flush() will most probably re-take the lock, so drop it first */ /* flush() will most probably re-take the lock, so drop it first */
LEAVE_BUFFERED(self) LEAVE_BUFFERED(self)
res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(flush));
if (!ENTER_BUFFERED(self)) if (!ENTER_BUFFERED(self))
return NULL; return NULL;
if (res == NULL) if (res == NULL)
@ -503,7 +503,7 @@ buffered_close(buffered *self, PyObject *args)
else else
Py_DECREF(res); Py_DECREF(res);
res = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_close); res = PyObject_CallMethodNoArgs(self->raw, &_Py_ID(close));
if (self->buffer) { if (self->buffer) {
PyMem_Free(self->buffer); PyMem_Free(self->buffer);
@ -530,7 +530,7 @@ buffered_detach(buffered *self, PyObject *Py_UNUSED(ignored))
{ {
PyObject *raw, *res; PyObject *raw, *res;
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(flush));
if (res == NULL) if (res == NULL)
return NULL; return NULL;
Py_DECREF(res); Py_DECREF(res);
@ -547,21 +547,21 @@ static PyObject *
buffered_seekable(buffered *self, PyObject *Py_UNUSED(ignored)) buffered_seekable(buffered *self, PyObject *Py_UNUSED(ignored))
{ {
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_seekable); return PyObject_CallMethodNoArgs(self->raw, &_Py_ID(seekable));
} }
static PyObject * static PyObject *
buffered_readable(buffered *self, PyObject *Py_UNUSED(ignored)) buffered_readable(buffered *self, PyObject *Py_UNUSED(ignored))
{ {
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_readable); return PyObject_CallMethodNoArgs(self->raw, &_Py_ID(readable));
} }
static PyObject * static PyObject *
buffered_writable(buffered *self, PyObject *Py_UNUSED(ignored)) buffered_writable(buffered *self, PyObject *Py_UNUSED(ignored))
{ {
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_writable); return PyObject_CallMethodNoArgs(self->raw, &_Py_ID(writable));
} }
static PyObject * static PyObject *
@ -584,14 +584,14 @@ static PyObject *
buffered_fileno(buffered *self, PyObject *Py_UNUSED(ignored)) buffered_fileno(buffered *self, PyObject *Py_UNUSED(ignored))
{ {
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_fileno); return PyObject_CallMethodNoArgs(self->raw, &_Py_ID(fileno));
} }
static PyObject * static PyObject *
buffered_isatty(buffered *self, PyObject *Py_UNUSED(ignored)) buffered_isatty(buffered *self, PyObject *Py_UNUSED(ignored))
{ {
CHECK_INITIALIZED(self) CHECK_INITIALIZED(self)
return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_isatty); return PyObject_CallMethodNoArgs(self->raw, &_Py_ID(isatty));
} }
/* Forward decls */ /* Forward decls */
@ -655,7 +655,7 @@ _buffered_raw_tell(buffered *self)
{ {
Py_off_t n; Py_off_t n;
PyObject *res; PyObject *res;
res = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_tell); res = PyObject_CallMethodNoArgs(self->raw, &_Py_ID(tell));
if (res == NULL) if (res == NULL)
return -1; return -1;
n = PyNumber_AsOff_t(res, PyExc_ValueError); n = PyNumber_AsOff_t(res, PyExc_ValueError);
@ -685,7 +685,7 @@ _buffered_raw_seek(buffered *self, Py_off_t target, int whence)
Py_DECREF(posobj); Py_DECREF(posobj);
return -1; return -1;
} }
res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_seek, res = PyObject_CallMethodObjArgs(self->raw, &_Py_ID(seek),
posobj, whenceobj, NULL); posobj, whenceobj, NULL);
Py_DECREF(posobj); Py_DECREF(posobj);
Py_DECREF(whenceobj); Py_DECREF(whenceobj);
@ -1152,7 +1152,7 @@ found:
Py_CLEAR(res); Py_CLEAR(res);
goto end; goto end;
} }
Py_XSETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks)); Py_XSETREF(res, _PyBytes_Join((PyObject *)&_Py_SINGLETON(bytes_empty), chunks));
end: end:
LEAVE_BUFFERED(self) LEAVE_BUFFERED(self)
@ -1311,7 +1311,7 @@ _io__Buffered_truncate_impl(buffered *self, PyObject *pos)
} }
Py_CLEAR(res); Py_CLEAR(res);
res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_truncate, pos); res = PyObject_CallMethodOneArg(self->raw, &_Py_ID(truncate), pos);
if (res == NULL) if (res == NULL)
goto end; goto end;
/* Reset cached position */ /* Reset cached position */
@ -1339,7 +1339,7 @@ buffered_iternext(buffered *self)
} }
else { else {
line = PyObject_CallMethodNoArgs((PyObject *)self, line = PyObject_CallMethodNoArgs((PyObject *)self,
_PyIO_str_readline); &_Py_ID(readline));
if (line && !PyBytes_Check(line)) { if (line && !PyBytes_Check(line)) {
PyErr_Format(PyExc_OSError, PyErr_Format(PyExc_OSError,
"readline() should have returned a bytes object, " "readline() should have returned a bytes object, "
@ -1457,7 +1457,7 @@ _bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len)
raised (see issue #10956). raised (see issue #10956).
*/ */
do { do {
res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_readinto, memobj); res = PyObject_CallMethodOneArg(self->raw, &_Py_ID(readinto), memobj);
} while (res == NULL && _PyIO_trap_eintr()); } while (res == NULL && _PyIO_trap_eintr());
Py_DECREF(memobj); Py_DECREF(memobj);
if (res == NULL) if (res == NULL)
@ -1530,7 +1530,7 @@ _bufferedreader_read_all(buffered *self)
} }
_bufferedreader_reset_buf(self); _bufferedreader_reset_buf(self);
if (_PyObject_LookupAttr(self->raw, _PyIO_str_readall, &readall) < 0) { if (_PyObject_LookupAttr(self->raw, &_Py_ID(readall), &readall) < 0) {
goto cleanup; goto cleanup;
} }
if (readall) { if (readall) {
@ -1565,7 +1565,7 @@ _bufferedreader_read_all(buffered *self)
} }
/* Read until EOF or until read() would block. */ /* Read until EOF or until read() would block. */
data = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_read); data = PyObject_CallMethodNoArgs(self->raw, &_Py_ID(read));
if (data == NULL) if (data == NULL)
goto cleanup; goto cleanup;
if (data != Py_None && !PyBytes_Check(data)) { if (data != Py_None && !PyBytes_Check(data)) {
@ -1578,7 +1578,7 @@ _bufferedreader_read_all(buffered *self)
goto cleanup; goto cleanup;
} }
else { else {
tmp = _PyBytes_Join(_PyIO_empty_bytes, chunks); tmp = _PyBytes_Join((PyObject *)&_Py_SINGLETON(bytes_empty), chunks);
res = tmp; res = tmp;
goto cleanup; goto cleanup;
} }
@ -1814,7 +1814,7 @@ _bufferedwriter_raw_write(buffered *self, char *start, Py_ssize_t len)
*/ */
do { do {
errno = 0; errno = 0;
res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_write, memobj); res = PyObject_CallMethodOneArg(self->raw, &_Py_ID(write), memobj);
errnum = errno; errnum = errno;
} while (res == NULL && _PyIO_trap_eintr()); } while (res == NULL && _PyIO_trap_eintr());
Py_DECREF(memobj); Py_DECREF(memobj);
@ -2251,7 +2251,7 @@ bufferedrwpair_closed_get(rwpair *self, void *context)
"the BufferedRWPair object is being garbage-collected"); "the BufferedRWPair object is being garbage-collected");
return NULL; return NULL;
} }
return PyObject_GetAttr((PyObject *) self->writer, _PyIO_str_closed); return PyObject_GetAttr((PyObject *) self->writer, &_Py_ID(closed));
} }

View file

@ -181,7 +181,7 @@ iobase_check_closed(PyObject *self)
int closed; int closed;
/* This gets the derived attribute, which is *not* __IOBase_closed /* This gets the derived attribute, which is *not* __IOBase_closed
in most cases! */ in most cases! */
closed = _PyObject_LookupAttr(self, _PyIO_str_closed, &res); closed = _PyObject_LookupAttr(self, &_Py_ID(closed), &res);
if (closed > 0) { if (closed > 0) {
closed = PyObject_IsTrue(res); closed = PyObject_IsTrue(res);
Py_DECREF(res); Py_DECREF(res);
@ -231,7 +231,7 @@ _io__IOBase_close_impl(PyObject *self)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
res = PyObject_CallMethodNoArgs(self, _PyIO_str_flush); res = PyObject_CallMethodNoArgs(self, &_Py_ID(flush));
PyErr_Fetch(&exc, &val, &tb); PyErr_Fetch(&exc, &val, &tb);
rc = PyObject_SetAttr(self, &_Py_ID(__IOBase_closed), Py_True); rc = PyObject_SetAttr(self, &_Py_ID(__IOBase_closed), Py_True);
@ -261,7 +261,7 @@ iobase_finalize(PyObject *self)
/* If `closed` doesn't exist or can't be evaluated as bool, then the /* If `closed` doesn't exist or can't be evaluated as bool, then the
object is probably in an unusable state, so ignore. */ object is probably in an unusable state, so ignore. */
if (_PyObject_LookupAttr(self, _PyIO_str_closed, &res) <= 0) { if (_PyObject_LookupAttr(self, &_Py_ID(closed), &res) <= 0) {
PyErr_Clear(); PyErr_Clear();
closed = -1; closed = -1;
} }
@ -276,7 +276,7 @@ iobase_finalize(PyObject *self)
finalization process. */ finalization process. */
if (PyObject_SetAttr(self, &_Py_ID(_finalizing), Py_True)) if (PyObject_SetAttr(self, &_Py_ID(_finalizing), Py_True))
PyErr_Clear(); PyErr_Clear();
res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_close); res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(close));
/* Silencing I/O errors is bad, but printing spurious tracebacks is /* Silencing I/O errors is bad, but printing spurious tracebacks is
equally as bad, and potentially more frequent (because of equally as bad, and potentially more frequent (because of
shutdown issues). */ shutdown issues). */
@ -377,7 +377,7 @@ _io__IOBase_seekable_impl(PyObject *self)
PyObject * PyObject *
_PyIOBase_check_seekable(PyObject *self, PyObject *args) _PyIOBase_check_seekable(PyObject *self, PyObject *args)
{ {
PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_seekable); PyObject *res = PyObject_CallMethodNoArgs(self, &_Py_ID(seekable));
if (res == NULL) if (res == NULL)
return NULL; return NULL;
if (res != Py_True) { if (res != Py_True) {
@ -410,7 +410,7 @@ _io__IOBase_readable_impl(PyObject *self)
PyObject * PyObject *
_PyIOBase_check_readable(PyObject *self, PyObject *args) _PyIOBase_check_readable(PyObject *self, PyObject *args)
{ {
PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_readable); PyObject *res = PyObject_CallMethodNoArgs(self, &_Py_ID(readable));
if (res == NULL) if (res == NULL)
return NULL; return NULL;
if (res != Py_True) { if (res != Py_True) {
@ -443,7 +443,7 @@ _io__IOBase_writable_impl(PyObject *self)
PyObject * PyObject *
_PyIOBase_check_writable(PyObject *self, PyObject *args) _PyIOBase_check_writable(PyObject *self, PyObject *args)
{ {
PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_writable); PyObject *res = PyObject_CallMethodNoArgs(self, &_Py_ID(writable));
if (res == NULL) if (res == NULL)
return NULL; return NULL;
if (res != Py_True) { if (res != Py_True) {
@ -472,7 +472,7 @@ iobase_enter(PyObject *self, PyObject *args)
static PyObject * static PyObject *
iobase_exit(PyObject *self, PyObject *args) iobase_exit(PyObject *self, PyObject *args)
{ {
return PyObject_CallMethodNoArgs(self, _PyIO_str_close); return PyObject_CallMethodNoArgs(self, &_Py_ID(close));
} }
/* Lower-level APIs */ /* Lower-level APIs */
@ -536,7 +536,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit)
PyObject *peek, *buffer, *result; PyObject *peek, *buffer, *result;
Py_ssize_t old_size = -1; Py_ssize_t old_size = -1;
if (_PyObject_LookupAttr(self, _PyIO_str_peek, &peek) < 0) { if (_PyObject_LookupAttr(self, &_Py_ID(peek), &peek) < 0) {
return NULL; return NULL;
} }
@ -650,7 +650,7 @@ iobase_iter(PyObject *self)
static PyObject * static PyObject *
iobase_iternext(PyObject *self) iobase_iternext(PyObject *self)
{ {
PyObject *line = PyObject_CallMethodNoArgs(self, _PyIO_str_readline); PyObject *line = PyObject_CallMethodNoArgs(self, &_Py_ID(readline));
if (line == NULL) if (line == NULL)
return NULL; return NULL;
@ -776,7 +776,7 @@ _io__IOBase_writelines(PyObject *self, PyObject *lines)
res = NULL; res = NULL;
do { do {
res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL); res = PyObject_CallMethodObjArgs(self, &_Py_ID(write), line, NULL);
} while (res == NULL && _PyIO_trap_eintr()); } while (res == NULL && _PyIO_trap_eintr());
Py_DECREF(line); Py_DECREF(line);
if (res == NULL) { if (res == NULL) {
@ -920,7 +920,7 @@ _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n)
if (b == NULL) if (b == NULL)
return NULL; return NULL;
res = PyObject_CallMethodObjArgs(self, _PyIO_str_readinto, b, NULL); res = PyObject_CallMethodObjArgs(self, &_Py_ID(readinto), b, NULL);
if (res == NULL || res == Py_None) { if (res == NULL || res == Py_None) {
Py_DECREF(b); Py_DECREF(b);
return res; return res;
@ -994,7 +994,7 @@ _io__RawIOBase_readall_impl(PyObject *self)
return NULL; return NULL;
} }
} }
result = _PyBytes_Join(_PyIO_empty_bytes, chunks); result = _PyBytes_Join((PyObject *)&_Py_SINGLETON(bytes_empty), chunks);
Py_DECREF(chunks); Py_DECREF(chunks);
return result; return result;
} }

View file

@ -192,7 +192,7 @@ write_str(stringio *self, PyObject *obj)
} }
if (self->writenl) { if (self->writenl) {
PyObject *translated = PyUnicode_Replace( PyObject *translated = PyUnicode_Replace(
decoded, _PyIO_str_nl, self->writenl, -1); decoded, &_Py_STR(newline), self->writenl, -1);
Py_DECREF(decoded); Py_DECREF(decoded);
decoded = translated; decoded = translated;
} }
@ -409,7 +409,7 @@ stringio_iternext(stringio *self)
else { else {
/* XXX is subclassing StringIO really supported? */ /* XXX is subclassing StringIO really supported? */
line = PyObject_CallMethodNoArgs((PyObject *)self, line = PyObject_CallMethodNoArgs((PyObject *)self,
_PyIO_str_readline); &_Py_ID(readline));
if (line && !PyUnicode_Check(line)) { if (line && !PyUnicode_Check(line)) {
PyErr_Format(PyExc_OSError, PyErr_Format(PyExc_OSError,
"readline() should have returned a str object, " "readline() should have returned a str object, "
@ -964,7 +964,7 @@ stringio_newlines(stringio *self, void *context)
CHECK_CLOSED(self); CHECK_CLOSED(self);
if (self->decoder == NULL) if (self->decoder == NULL)
Py_RETURN_NONE; Py_RETURN_NONE;
return PyObject_GetAttr(self->decoder, _PyIO_str_newlines); return PyObject_GetAttr(self->decoder, &_Py_ID(newlines));
} }
#include "clinic/stringio.c.h" #include "clinic/stringio.c.h"

View file

@ -298,7 +298,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself,
/* decode input (with the eventual \r from a previous pass) */ /* decode input (with the eventual \r from a previous pass) */
if (self->decoder != Py_None) { if (self->decoder != Py_None) {
output = PyObject_CallMethodObjArgs(self->decoder, output = PyObject_CallMethodObjArgs(self->decoder,
_PyIO_str_decode, input, final ? Py_True : Py_False, NULL); &_Py_ID(decode), input, final ? Py_True : Py_False, NULL);
} }
else { else {
output = input; output = input;
@ -509,7 +509,7 @@ _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self)
if (self->decoder != Py_None) { if (self->decoder != Py_None) {
PyObject *state = PyObject_CallMethodNoArgs(self->decoder, PyObject *state = PyObject_CallMethodNoArgs(self->decoder,
_PyIO_str_getstate); &_Py_ID(getstate));
if (state == NULL) if (state == NULL)
return NULL; return NULL;
if (!PyTuple_Check(state)) { if (!PyTuple_Check(state)) {
@ -584,7 +584,7 @@ _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self)
self->seennl = 0; self->seennl = 0;
self->pendingcr = 0; self->pendingcr = 0;
if (self->decoder != Py_None) if (self->decoder != Py_None)
return PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); return PyObject_CallMethodNoArgs(self->decoder, &_Py_ID(reset));
else else
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -883,7 +883,7 @@ _textiowrapper_decode(PyObject *decoder, PyObject *bytes, int eof)
if (Py_IS_TYPE(decoder, &PyIncrementalNewlineDecoder_Type)) if (Py_IS_TYPE(decoder, &PyIncrementalNewlineDecoder_Type))
chars = _PyIncrementalNewlineDecoder_decode(decoder, bytes, eof); chars = _PyIncrementalNewlineDecoder_decode(decoder, bytes, eof);
else else
chars = PyObject_CallMethodObjArgs(decoder, _PyIO_str_decode, bytes, chars = PyObject_CallMethodObjArgs(decoder, &_Py_ID(decode), bytes,
eof ? Py_True : Py_False, NULL); eof ? Py_True : Py_False, NULL);
if (check_decoded(chars) < 0) if (check_decoded(chars) < 0)
@ -947,7 +947,7 @@ _textiowrapper_fix_encoder_state(textio *self)
self->encoding_start_of_stream = 1; self->encoding_start_of_stream = 1;
PyObject *cookieObj = PyObject_CallMethodNoArgs( PyObject *cookieObj = PyObject_CallMethodNoArgs(
self->buffer, _PyIO_str_tell); self->buffer, &_Py_ID(tell));
if (cookieObj == NULL) { if (cookieObj == NULL) {
return -1; return -1;
} }
@ -961,7 +961,7 @@ _textiowrapper_fix_encoder_state(textio *self)
if (cmp == 0) { if (cmp == 0) {
self->encoding_start_of_stream = 0; self->encoding_start_of_stream = 0;
PyObject *res = PyObject_CallMethodOneArg( PyObject *res = PyObject_CallMethodOneArg(
self->encoder, _PyIO_str_setstate, _PyLong_GetZero()); self->encoder, &_Py_ID(setstate), _PyLong_GetZero());
if (res == NULL) { if (res == NULL) {
return -1; return -1;
} }
@ -1225,7 +1225,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
goto error; goto error;
self->seekable = self->telling = r; self->seekable = self->telling = r;
r = _PyObject_LookupAttr(buffer, _PyIO_str_read1, &res); r = _PyObject_LookupAttr(buffer, &_Py_ID(read1), &res);
if (r < 0) { if (r < 0) {
goto error; goto error;
} }
@ -1358,7 +1358,7 @@ _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding,
return NULL; return NULL;
} }
PyObject *res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); PyObject *res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(flush));
if (res == NULL) { if (res == NULL) {
return NULL; return NULL;
} }
@ -1497,7 +1497,7 @@ _io_TextIOWrapper_detach_impl(textio *self)
{ {
PyObject *buffer, *res; PyObject *buffer, *res;
CHECK_ATTACHED(self); CHECK_ATTACHED(self);
res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(flush));
if (res == NULL) if (res == NULL)
return NULL; return NULL;
Py_DECREF(res); Py_DECREF(res);
@ -1569,7 +1569,7 @@ _textiowrapper_writeflush(textio *self)
PyObject *ret; PyObject *ret;
do { do {
ret = PyObject_CallMethodOneArg(self->buffer, _PyIO_str_write, b); ret = PyObject_CallMethodOneArg(self->buffer, &_Py_ID(write), b);
} while (ret == NULL && _PyIO_trap_eintr()); } while (ret == NULL && _PyIO_trap_eintr());
Py_DECREF(b); Py_DECREF(b);
// NOTE: We cleared buffer but we don't know how many bytes are actually written // NOTE: We cleared buffer but we don't know how many bytes are actually written
@ -1644,7 +1644,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
self->encoding_start_of_stream = 0; self->encoding_start_of_stream = 0;
} }
else { else {
b = PyObject_CallMethodOneArg(self->encoder, _PyIO_str_encode, text); b = PyObject_CallMethodOneArg(self->encoder, &_Py_ID(encode), text);
} }
Py_DECREF(text); Py_DECREF(text);
@ -1704,7 +1704,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
} }
if (needflush) { if (needflush) {
ret = PyObject_CallMethodNoArgs(self->buffer, _PyIO_str_flush); ret = PyObject_CallMethodNoArgs(self->buffer, &_Py_ID(flush));
if (ret == NULL) if (ret == NULL)
return NULL; return NULL;
Py_DECREF(ret); Py_DECREF(ret);
@ -1795,7 +1795,7 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint)
* where the decoder's input buffer is empty. * where the decoder's input buffer is empty.
*/ */
PyObject *state = PyObject_CallMethodNoArgs(self->decoder, PyObject *state = PyObject_CallMethodNoArgs(self->decoder,
_PyIO_str_getstate); &_Py_ID(getstate));
if (state == NULL) if (state == NULL)
return -1; return -1;
/* Given this, we know there was a valid snapshot point /* Given this, we know there was a valid snapshot point
@ -1836,7 +1836,7 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint)
goto fail; goto fail;
input_chunk = PyObject_CallMethodOneArg(self->buffer, input_chunk = PyObject_CallMethodOneArg(self->buffer,
(self->has_read1 ? _PyIO_str_read1: _PyIO_str_read), (self->has_read1 ? &_Py_ID(read1): &_Py_ID(read)),
chunk_size); chunk_size);
Py_DECREF(chunk_size); Py_DECREF(chunk_size);
if (input_chunk == NULL) if (input_chunk == NULL)
@ -1928,7 +1928,7 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
bytes, 1); bytes, 1);
else else
decoded = PyObject_CallMethodObjArgs( decoded = PyObject_CallMethodObjArgs(
self->decoder, _PyIO_str_decode, bytes, Py_True, NULL); self->decoder, &_Py_ID(decode), bytes, Py_True, NULL);
Py_DECREF(bytes); Py_DECREF(bytes);
if (check_decoded(decoded) < 0) if (check_decoded(decoded) < 0)
goto fail; goto fail;
@ -1989,7 +1989,7 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
if (chunks != NULL) { if (chunks != NULL) {
if (result != NULL && PyList_Append(chunks, result) < 0) if (result != NULL && PyList_Append(chunks, result) < 0)
goto fail; goto fail;
Py_XSETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks)); Py_XSETREF(result, PyUnicode_Join(&_Py_STR(empty), chunks));
if (result == NULL) if (result == NULL)
goto fail; goto fail;
Py_CLEAR(chunks); Py_CLEAR(chunks);
@ -2254,14 +2254,13 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit)
goto error; goto error;
Py_DECREF(line); Py_DECREF(line);
} }
line = PyUnicode_Join(_PyIO_empty_str, chunks); line = PyUnicode_Join(&_Py_STR(empty), chunks);
if (line == NULL) if (line == NULL)
goto error; goto error;
Py_CLEAR(chunks); Py_CLEAR(chunks);
} }
if (line == NULL) { if (line == NULL) {
Py_INCREF(_PyIO_empty_str); line = &_Py_STR(empty);
line = _PyIO_empty_str;
} }
return line; return line;
@ -2379,7 +2378,7 @@ _textiowrapper_decoder_setstate(textio *self, cookie_type *cookie)
utf-16, that we are expecting a BOM). utf-16, that we are expecting a BOM).
*/ */
if (cookie->start_pos == 0 && cookie->dec_flags == 0) { if (cookie->start_pos == 0 && cookie->dec_flags == 0) {
res = PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); res = PyObject_CallMethodNoArgs(self->decoder, &_Py_ID(reset));
} }
else { else {
res = _PyObject_CallMethod(self->decoder, &_Py_ID(setstate), res = _PyObject_CallMethod(self->decoder, &_Py_ID(setstate),
@ -2397,11 +2396,11 @@ _textiowrapper_encoder_reset(textio *self, int start_of_stream)
{ {
PyObject *res; PyObject *res;
if (start_of_stream) { if (start_of_stream) {
res = PyObject_CallMethodNoArgs(self->encoder, _PyIO_str_reset); res = PyObject_CallMethodNoArgs(self->encoder, &_Py_ID(reset));
self->encoding_start_of_stream = 1; self->encoding_start_of_stream = 1;
} }
else { else {
res = PyObject_CallMethodOneArg(self->encoder, _PyIO_str_setstate, res = PyObject_CallMethodOneArg(self->encoder, &_Py_ID(setstate),
_PyLong_GetZero()); _PyLong_GetZero());
self->encoding_start_of_stream = 0; self->encoding_start_of_stream = 0;
} }
@ -2528,7 +2527,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
goto fail; goto fail;
} }
res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(flush));
if (res == NULL) if (res == NULL)
goto fail; goto fail;
Py_DECREF(res); Py_DECREF(res);
@ -2543,7 +2542,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
posobj = PyLong_FromOff_t(cookie.start_pos); posobj = PyLong_FromOff_t(cookie.start_pos);
if (posobj == NULL) if (posobj == NULL)
goto fail; goto fail;
res = PyObject_CallMethodOneArg(self->buffer, _PyIO_str_seek, posobj); res = PyObject_CallMethodOneArg(self->buffer, &_Py_ID(seek), posobj);
Py_DECREF(posobj); Py_DECREF(posobj);
if (res == NULL) if (res == NULL)
goto fail; goto fail;
@ -2692,14 +2691,14 @@ _io_TextIOWrapper_tell_impl(textio *self)
/* Decoder state will be restored at the end */ /* Decoder state will be restored at the end */
saved_state = PyObject_CallMethodNoArgs(self->decoder, saved_state = PyObject_CallMethodNoArgs(self->decoder,
_PyIO_str_getstate); &_Py_ID(getstate));
if (saved_state == NULL) if (saved_state == NULL)
goto fail; goto fail;
#define DECODER_GETSTATE() do { \ #define DECODER_GETSTATE() do { \
PyObject *dec_buffer; \ PyObject *dec_buffer; \
PyObject *_state = PyObject_CallMethodNoArgs(self->decoder, \ PyObject *_state = PyObject_CallMethodNoArgs(self->decoder, \
_PyIO_str_getstate); \ &_Py_ID(getstate)); \
if (_state == NULL) \ if (_state == NULL) \
goto fail; \ goto fail; \
if (!PyTuple_Check(_state)) { \ if (!PyTuple_Check(_state)) { \
@ -2863,12 +2862,12 @@ _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos)
CHECK_ATTACHED(self) CHECK_ATTACHED(self)
res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(flush));
if (res == NULL) if (res == NULL)
return NULL; return NULL;
Py_DECREF(res); Py_DECREF(res);
return PyObject_CallMethodOneArg(self->buffer, _PyIO_str_truncate, pos); return PyObject_CallMethodOneArg(self->buffer, &_Py_ID(truncate), pos);
} }
static PyObject * static PyObject *
@ -3077,7 +3076,7 @@ textiowrapper_iternext(textio *self)
} }
else { else {
line = PyObject_CallMethodNoArgs((PyObject *)self, line = PyObject_CallMethodNoArgs((PyObject *)self,
_PyIO_str_readline); &_Py_ID(readline));
if (line && !PyUnicode_Check(line)) { if (line && !PyUnicode_Check(line)) {
PyErr_Format(PyExc_OSError, PyErr_Format(PyExc_OSError,
"readline() should have returned a str object, " "readline() should have returned a str object, "
@ -3112,7 +3111,7 @@ static PyObject *
textiowrapper_closed_get(textio *self, void *context) textiowrapper_closed_get(textio *self, void *context)
{ {
CHECK_ATTACHED(self); CHECK_ATTACHED(self);
return PyObject_GetAttr(self->buffer, _PyIO_str_closed); return PyObject_GetAttr(self->buffer, &_Py_ID(closed));
} }
static PyObject * static PyObject *
@ -3121,7 +3120,7 @@ textiowrapper_newlines_get(textio *self, void *context)
PyObject *res; PyObject *res;
CHECK_ATTACHED(self); CHECK_ATTACHED(self);
if (self->decoder == NULL || if (self->decoder == NULL ||
_PyObject_LookupAttr(self->decoder, _PyIO_str_newlines, &res) == 0) _PyObject_LookupAttr(self->decoder, &_Py_ID(newlines), &res) == 0)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }

View file

@ -3,6 +3,7 @@
#include "pycore_gc.h" // PyGC_Head #include "pycore_gc.h" // PyGC_Head
#include "pycore_hashtable.h" // _Py_hashtable_t #include "pycore_hashtable.h" // _Py_hashtable_t
#include "pycore_pymem.h" // _Py_tracemalloc_config #include "pycore_pymem.h" // _Py_tracemalloc_config
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_traceback.h" #include "pycore_traceback.h"
#include <pycore_frame.h> #include <pycore_frame.h>
@ -15,6 +16,8 @@ module _tracemalloc
[clinic start generated code]*/ [clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=708a98302fc46e5f]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=708a98302fc46e5f]*/
_Py_DECLARE_STR(anon_unknown, "<unknown>");
/* Trace memory blocks allocated by PyMem_RawMalloc() */ /* Trace memory blocks allocated by PyMem_RawMalloc() */
#define TRACE_RAW_MALLOC #define TRACE_RAW_MALLOC
@ -91,7 +94,6 @@ typedef struct {
static const unsigned long MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1)); static const unsigned long MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1));
static PyObject *unknown_filename = NULL;
static traceback_t tracemalloc_empty_traceback; static traceback_t tracemalloc_empty_traceback;
/* Trace of a memory block */ /* Trace of a memory block */
@ -305,7 +307,7 @@ hashtable_compare_traceback(const void *key1, const void *key2)
static void static void
tracemalloc_get_frame(InterpreterFrame *pyframe, frame_t *frame) tracemalloc_get_frame(InterpreterFrame *pyframe, frame_t *frame)
{ {
frame->filename = unknown_filename; frame->filename = &_Py_STR(anon_unknown);
int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*sizeof(_Py_CODEUNIT)); int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*sizeof(_Py_CODEUNIT));
if (lineno < 0) { if (lineno < 0) {
lineno = 0; lineno = 0;
@ -905,15 +907,10 @@ tracemalloc_init(void)
return -1; return -1;
} }
unknown_filename = PyUnicode_FromString("<unknown>");
if (unknown_filename == NULL)
return -1;
PyUnicode_InternInPlace(&unknown_filename);
tracemalloc_empty_traceback.nframe = 1; tracemalloc_empty_traceback.nframe = 1;
tracemalloc_empty_traceback.total_nframe = 1; tracemalloc_empty_traceback.total_nframe = 1;
/* borrowed reference */ /* borrowed reference */
tracemalloc_empty_traceback.frames[0].filename = unknown_filename; tracemalloc_empty_traceback.frames[0].filename = &_Py_STR(anon_unknown);
tracemalloc_empty_traceback.frames[0].lineno = 0; tracemalloc_empty_traceback.frames[0].lineno = 0;
tracemalloc_empty_traceback.hash = traceback_hash(&tracemalloc_empty_traceback); tracemalloc_empty_traceback.hash = traceback_hash(&tracemalloc_empty_traceback);
@ -947,8 +944,6 @@ tracemalloc_deinit(void)
#ifdef REENTRANT_THREADLOCAL #ifdef REENTRANT_THREADLOCAL
PyThread_tss_delete(&tracemalloc_reentrant_key); PyThread_tss_delete(&tracemalloc_reentrant_key);
#endif #endif
Py_XDECREF(unknown_filename);
} }

View file

@ -1,26 +1,15 @@
/* Boolean type, a subtype of int */ /* Boolean type, a subtype of int */
#include "Python.h" #include "Python.h"
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_pyerrors.h" // _Py_FatalRefcountError() #include "pycore_pyerrors.h" // _Py_FatalRefcountError()
/* We define bool_repr to return "False" or "True" */ /* We define bool_repr to return "False" or "True" */
static PyObject *false_str = NULL;
static PyObject *true_str = NULL;
static PyObject * static PyObject *
bool_repr(PyObject *self) bool_repr(PyObject *self)
{ {
PyObject *s; return self == Py_True ? &_Py_ID(True) : &_Py_ID(False);
if (self == Py_True)
s = true_str ? true_str :
(true_str = PyUnicode_InternFromString("True"));
else
s = false_str ? false_str :
(false_str = PyUnicode_InternFromString("False"));
Py_XINCREF(s);
return s;
} }
/* Function to return a bool from a C long */ /* Function to return a bool from a C long */

View file

@ -157,13 +157,7 @@ static PyMemberDef method_memberlist[] = {
static PyObject * static PyObject *
method_get_doc(PyMethodObject *im, void *context) method_get_doc(PyMethodObject *im, void *context)
{ {
static PyObject *docstr; return PyObject_GetAttr(im->im_func, &_Py_ID(__doc__));
if (docstr == NULL) {
docstr= PyUnicode_InternFromString("__doc__");
if (docstr == NULL)
return NULL;
}
return PyObject_GetAttr(im->im_func, docstr);
} }
static PyGetSetDef method_getset[] = { static PyGetSetDef method_getset[] = {
@ -405,13 +399,8 @@ static PyMemberDef instancemethod_memberlist[] = {
static PyObject * static PyObject *
instancemethod_get_doc(PyObject *self, void *context) instancemethod_get_doc(PyObject *self, void *context)
{ {
static PyObject *docstr; return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self),
if (docstr == NULL) { &_Py_ID(__doc__));
docstr = PyUnicode_InternFromString("__doc__");
if (docstr == NULL)
return NULL;
}
return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self), docstr);
} }
static PyGetSetDef instancemethod_getset[] = { static PyGetSetDef instancemethod_getset[] = {

View file

@ -553,16 +553,11 @@ PyCode_New(int argcount, int kwonlyargcount,
PyCodeObject * PyCodeObject *
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno) PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
{ {
PyObject *emptystring = NULL;
PyObject *nulltuple = NULL; PyObject *nulltuple = NULL;
PyObject *filename_ob = NULL; PyObject *filename_ob = NULL;
PyObject *funcname_ob = NULL; PyObject *funcname_ob = NULL;
PyCodeObject *result = NULL; PyCodeObject *result = NULL;
emptystring = PyBytes_FromString("");
if (emptystring == NULL) {
goto failed;
}
nulltuple = PyTuple_New(0); nulltuple = PyTuple_New(0);
if (nulltuple == NULL) { if (nulltuple == NULL) {
goto failed; goto failed;
@ -576,6 +571,7 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
goto failed; goto failed;
} }
#define emptystring (PyObject *)&_Py_SINGLETON(bytes_empty)
struct _PyCodeConstructor con = { struct _PyCodeConstructor con = {
.filename = filename_ob, .filename = filename_ob,
.name = funcname_ob, .name = funcname_ob,
@ -594,7 +590,6 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
result = _PyCode_New(&con); result = _PyCode_New(&con);
failed: failed:
Py_XDECREF(emptystring);
Py_XDECREF(nulltuple); Py_XDECREF(nulltuple);
Py_XDECREF(funcname_ob); Py_XDECREF(funcname_ob);
Py_XDECREF(filename_ob); Py_XDECREF(filename_ob);

View file

@ -15,7 +15,7 @@ class list "PyListObject *" "&PyList_Type"
#include "clinic/listobject.c.h" #include "clinic/listobject.c.h"
static PyObject *indexerr = NULL; _Py_DECLARE_STR(list_err, "list index out of range");
#if PyList_MAXFREELIST > 0 #if PyList_MAXFREELIST > 0
static struct _Py_list_state * static struct _Py_list_state *
@ -125,10 +125,6 @@ _PyList_Fini(PyInterpreterState *interp)
struct _Py_list_state *state = &interp->list; struct _Py_list_state *state = &interp->list;
state->numfree = -1; state->numfree = -1;
#endif #endif
if (_Py_IsMainInterpreter(interp)) {
Py_CLEAR(indexerr);
}
} }
/* Print summary info about the state of the optimized allocator */ /* Print summary info about the state of the optimized allocator */
@ -238,13 +234,8 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
return NULL; return NULL;
} }
if (!valid_index(i, Py_SIZE(op))) { if (!valid_index(i, Py_SIZE(op))) {
if (indexerr == NULL) { _Py_DECLARE_STR(list_err, "list index out of range");
indexerr = PyUnicode_FromString( PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
"list index out of range");
if (indexerr == NULL)
return NULL;
}
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL; return NULL;
} }
return ((PyListObject *)op) -> ob_item[i]; return ((PyListObject *)op) -> ob_item[i];
@ -452,13 +443,7 @@ static PyObject *
list_item(PyListObject *a, Py_ssize_t i) list_item(PyListObject *a, Py_ssize_t i)
{ {
if (!valid_index(i, Py_SIZE(a))) { if (!valid_index(i, Py_SIZE(a))) {
if (indexerr == NULL) { PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
indexerr = PyUnicode_FromString(
"list index out of range");
if (indexerr == NULL)
return NULL;
}
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL; return NULL;
} }
Py_INCREF(a->ob_item[i]); Py_INCREF(a->ob_item[i]);

View file

@ -768,25 +768,6 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message,
static int static int
is_internal_frame(PyFrameObject *frame) is_internal_frame(PyFrameObject *frame)
{ {
static PyObject *importlib_string = NULL;
static PyObject *bootstrap_string = NULL;
int contains;
if (importlib_string == NULL) {
importlib_string = PyUnicode_FromString("importlib");
if (importlib_string == NULL) {
return 0;
}
bootstrap_string = PyUnicode_FromString("_bootstrap");
if (bootstrap_string == NULL) {
Py_DECREF(importlib_string);
return 0;
}
Py_INCREF(importlib_string);
Py_INCREF(bootstrap_string);
}
if (frame == NULL) { if (frame == NULL) {
return 0; return 0;
} }
@ -802,12 +783,12 @@ is_internal_frame(PyFrameObject *frame)
return 0; return 0;
} }
contains = PyUnicode_Contains(filename, importlib_string); int contains = PyUnicode_Contains(filename, &_Py_ID(importlib));
if (contains < 0) { if (contains < 0) {
return 0; return 0;
} }
else if (contains > 0) { else if (contains > 0) {
contains = PyUnicode_Contains(filename, bootstrap_string); contains = PyUnicode_Contains(filename, &_Py_ID(_bootstrap));
if (contains < 0) { if (contains < 0) {
return 0; return 0;
} }

View file

@ -1,5 +1,6 @@
#include "Python.h" #include "Python.h"
#include "pycore_ast.h" // expr_ty #include "pycore_ast.h" // expr_ty
#include "pycore_runtime.h" // _Py_ID()
#include <float.h> // DBL_MAX_10_EXP #include <float.h> // DBL_MAX_10_EXP
#include <stdbool.h> #include <stdbool.h>
@ -8,11 +9,10 @@
* See ast.unparse for a full unparser (written in Python) * See ast.unparse for a full unparser (written in Python)
*/ */
static PyObject *_str_open_br; _Py_DECLARE_STR(open_br, "{");
static PyObject *_str_dbl_open_br; _Py_DECLARE_STR(dbl_open_br, "{{");
static PyObject *_str_close_br; _Py_DECLARE_STR(close_br, "}");
static PyObject *_str_dbl_close_br; _Py_DECLARE_STR(dbl_close_br, "}}");
static PyObject *_str_inf;
static PyObject *_str_replace_inf; static PyObject *_str_replace_inf;
/* Forward declarations for recursion via helper functions. */ /* Forward declarations for recursion via helper functions. */
@ -80,7 +80,7 @@ append_repr(_PyUnicodeWriter *writer, PyObject *obj)
{ {
PyObject *new_repr = PyUnicode_Replace( PyObject *new_repr = PyUnicode_Replace(
repr, repr,
_str_inf, &_Py_ID(inf),
_str_replace_inf, _str_replace_inf,
-1 -1
); );
@ -575,11 +575,11 @@ escape_braces(PyObject *orig)
{ {
PyObject *temp; PyObject *temp;
PyObject *result; PyObject *result;
temp = PyUnicode_Replace(orig, _str_open_br, _str_dbl_open_br, -1); temp = PyUnicode_Replace(orig, &_Py_STR(open_br), &_Py_STR(dbl_open_br), -1);
if (!temp) { if (!temp) {
return NULL; return NULL;
} }
result = PyUnicode_Replace(temp, _str_close_br, _str_dbl_close_br, -1); result = PyUnicode_Replace(temp, &_Py_STR(close_br), &_Py_STR(dbl_close_br), -1);
Py_DECREF(temp); Py_DECREF(temp);
return result; return result;
} }
@ -673,7 +673,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e)
if (!temp_fv_str) { if (!temp_fv_str) {
return -1; return -1;
} }
if (PyUnicode_Find(temp_fv_str, _str_open_br, 0, 1, 1) == 0) { if (PyUnicode_Find(temp_fv_str, &_Py_STR(open_br), 0, 1, 1) == 0) {
/* Expression starts with a brace, split it with a space from the outer /* Expression starts with a brace, split it with a space from the outer
one. */ one. */
outer_brace = "{ "; outer_brace = "{ ";
@ -927,26 +927,6 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level)
static int static int
maybe_init_static_strings(void) maybe_init_static_strings(void)
{ {
if (!_str_open_br &&
!(_str_open_br = PyUnicode_InternFromString("{"))) {
return -1;
}
if (!_str_dbl_open_br &&
!(_str_dbl_open_br = PyUnicode_InternFromString("{{"))) {
return -1;
}
if (!_str_close_br &&
!(_str_close_br = PyUnicode_InternFromString("}"))) {
return -1;
}
if (!_str_dbl_close_br &&
!(_str_dbl_close_br = PyUnicode_InternFromString("}}"))) {
return -1;
}
if (!_str_inf &&
!(_str_inf = PyUnicode_FromString("inf"))) {
return -1;
}
if (!_str_replace_inf && if (!_str_replace_inf &&
!(_str_replace_inf = PyUnicode_FromFormat("1e%d", 1 + DBL_MAX_10_EXP))) { !(_str_replace_inf = PyUnicode_FromFormat("1e%d", 1 + DBL_MAX_10_EXP))) {
return -1; return -1;

View file

@ -2522,7 +2522,6 @@ static int
compiler_class(struct compiler *c, stmt_ty s) compiler_class(struct compiler *c, stmt_ty s)
{ {
PyCodeObject *co; PyCodeObject *co;
PyObject *str;
int i, firstlineno; int i, firstlineno;
asdl_expr_seq *decos = s->v.ClassDef.decorator_list; asdl_expr_seq *decos = s->v.ClassDef.decorator_list;
@ -2557,30 +2556,21 @@ compiler_class(struct compiler *c, stmt_ty s)
Py_INCREF(s->v.ClassDef.name); Py_INCREF(s->v.ClassDef.name);
Py_XSETREF(c->u->u_private, s->v.ClassDef.name); Py_XSETREF(c->u->u_private, s->v.ClassDef.name);
/* load (global) __name__ ... */ /* load (global) __name__ ... */
str = PyUnicode_InternFromString("__name__"); if (!compiler_nameop(c, &_Py_ID(__name__), Load)) {
if (!str || !compiler_nameop(c, str, Load)) {
Py_XDECREF(str);
compiler_exit_scope(c); compiler_exit_scope(c);
return 0; return 0;
} }
Py_DECREF(str);
/* ... and store it as __module__ */ /* ... and store it as __module__ */
str = PyUnicode_InternFromString("__module__"); if (!compiler_nameop(c, &_Py_ID(__module__), Store)) {
if (!str || !compiler_nameop(c, str, Store)) {
Py_XDECREF(str);
compiler_exit_scope(c); compiler_exit_scope(c);
return 0; return 0;
} }
Py_DECREF(str);
assert(c->u->u_qualname); assert(c->u->u_qualname);
ADDOP_LOAD_CONST(c, c->u->u_qualname); ADDOP_LOAD_CONST(c, c->u->u_qualname);
str = PyUnicode_InternFromString("__qualname__"); if (!compiler_nameop(c, &_Py_ID(__qualname__), Store)) {
if (!str || !compiler_nameop(c, str, Store)) {
Py_XDECREF(str);
compiler_exit_scope(c); compiler_exit_scope(c);
return 0; return 0;
} }
Py_DECREF(str);
/* compile the body proper */ /* compile the body proper */
if (!compiler_body(c, s->v.ClassDef.body)) { if (!compiler_body(c, s->v.ClassDef.body)) {
compiler_exit_scope(c); compiler_exit_scope(c);
@ -2591,13 +2581,7 @@ compiler_class(struct compiler *c, stmt_ty s)
/* Return __classcell__ if it is referenced, otherwise return None */ /* Return __classcell__ if it is referenced, otherwise return None */
if (c->u->u_ste->ste_needs_class_closure) { if (c->u->u_ste->ste_needs_class_closure) {
/* Store __classcell__ into class namespace & return it */ /* Store __classcell__ into class namespace & return it */
str = PyUnicode_InternFromString("__class__"); i = compiler_lookup_arg(c->u->u_cellvars, &_Py_ID(__class__));
if (str == NULL) {
compiler_exit_scope(c);
return 0;
}
i = compiler_lookup_arg(c->u->u_cellvars, str);
Py_DECREF(str);
if (i < 0) { if (i < 0) {
compiler_exit_scope(c); compiler_exit_scope(c);
return 0; return 0;
@ -2606,13 +2590,10 @@ compiler_class(struct compiler *c, stmt_ty s)
ADDOP_I(c, LOAD_CLOSURE, i); ADDOP_I(c, LOAD_CLOSURE, i);
ADDOP_I(c, COPY, 1); ADDOP_I(c, COPY, 1);
str = PyUnicode_InternFromString("__classcell__"); if (!compiler_nameop(c, &_Py_ID(__classcell__), Store)) {
if (!str || !compiler_nameop(c, str, Store)) {
Py_XDECREF(str);
compiler_exit_scope(c); compiler_exit_scope(c);
return 0; return 0;
} }
Py_DECREF(str);
} }
else { else {
/* No methods referenced __class__, so just return None */ /* No methods referenced __class__, so just return None */
@ -4741,13 +4722,8 @@ compiler_joined_str(struct compiler *c, expr_ty e)
Py_ssize_t value_count = asdl_seq_LEN(e->v.JoinedStr.values); Py_ssize_t value_count = asdl_seq_LEN(e->v.JoinedStr.values);
if (value_count > STACK_USE_GUIDELINE) { if (value_count > STACK_USE_GUIDELINE) {
ADDOP_LOAD_CONST_NEW(c, _PyUnicode_FromASCII("", 0)); ADDOP_LOAD_CONST_NEW(c, &_Py_STR(empty));
PyObject *join = _PyUnicode_FromASCII("join", 4); ADDOP_NAME(c, LOAD_METHOD, &_Py_ID(join), names);
if (join == NULL) {
return 0;
}
ADDOP_NAME(c, LOAD_METHOD, join, names);
Py_DECREF(join);
ADDOP_I(c, BUILD_LIST, 0); ADDOP_I(c, BUILD_LIST, 0);
for (Py_ssize_t i = 0; i < asdl_seq_LEN(e->v.JoinedStr.values); i++) { for (Py_ssize_t i = 0; i < asdl_seq_LEN(e->v.JoinedStr.values); i++) {
VISIT(c, expr, asdl_seq_GET(e->v.JoinedStr.values, i)); VISIT(c, expr, asdl_seq_GET(e->v.JoinedStr.values, i));

View file

@ -24,7 +24,6 @@
#include "pycore_runtime.h" // _Py_ID() #include "pycore_runtime.h" // _Py_ID()
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT #include "pycore_runtime_init.h" // _PyRuntimeState_INIT
#include "pycore_sliceobject.h" // _PySlice_Fini() #include "pycore_sliceobject.h" // _PySlice_Fini()
#include "pycore_symtable.h" // _PySymtable_Fini()
#include "pycore_sysmodule.h" // _PySys_ClearAuditHooks() #include "pycore_sysmodule.h" // _PySys_ClearAuditHooks()
#include "pycore_traceback.h" // _Py_DumpTracebackThreads() #include "pycore_traceback.h" // _Py_DumpTracebackThreads()
#include "pycore_tuple.h" // _PyTuple_InitTypes() #include "pycore_tuple.h" // _PyTuple_InitTypes()
@ -1690,9 +1689,6 @@ finalize_interp_clear(PyThreadState *tstate)
int is_main_interp = _Py_IsMainInterpreter(tstate->interp); int is_main_interp = _Py_IsMainInterpreter(tstate->interp);
_PyExc_ClearExceptionGroupType(tstate->interp); _PyExc_ClearExceptionGroupType(tstate->interp);
if (is_main_interp) {
_PySymtable_Fini();
}
/* Clear interpreter state and all thread states */ /* Clear interpreter state and all thread states */
_PyInterpreterState_Clear(tstate); _PyInterpreterState_Clear(tstate);

View file

@ -230,13 +230,6 @@ static int symtable_raise_if_annotation_block(struct symtable *st, const char *,
static int symtable_raise_if_comprehension_block(struct symtable *st, expr_ty); static int symtable_raise_if_comprehension_block(struct symtable *st, expr_ty);
static identifier top = NULL, lambda = NULL, genexpr = NULL,
listcomp = NULL, setcomp = NULL, dictcomp = NULL,
__class__ = NULL, _annotation = NULL;
#define GET_IDENTIFIER(VAR) \
((VAR) ? (VAR) : ((VAR) = PyUnicode_InternFromString(# VAR)))
#define DUPLICATE_ARGUMENT \ #define DUPLICATE_ARGUMENT \
"duplicate argument '%U' in function definition" "duplicate argument '%U' in function definition"
@ -313,8 +306,7 @@ _PySymtable_Build(mod_ty mod, PyObject *filename, PyFutureFeatures *future)
recursion_limit * COMPILER_STACK_FRAME_SCALE : recursion_limit; recursion_limit * COMPILER_STACK_FRAME_SCALE : recursion_limit;
/* Make the initial symbol information gathering pass */ /* Make the initial symbol information gathering pass */
if (!GET_IDENTIFIER(top) || if (!symtable_enter_block(st, &_Py_ID(top), ModuleBlock, (void *)mod, 0, 0, 0, 0)) {
!symtable_enter_block(st, top, ModuleBlock, (void *)mod, 0, 0, 0, 0)) {
_PySymtable_Free(st); _PySymtable_Free(st);
return NULL; return NULL;
} }
@ -619,9 +611,7 @@ static int
drop_class_free(PySTEntryObject *ste, PyObject *free) drop_class_free(PySTEntryObject *ste, PyObject *free)
{ {
int res; int res;
if (!GET_IDENTIFIER(__class__)) res = PySet_Discard(free, &_Py_ID(__class__));
return 0;
res = PySet_Discard(free, __class__);
if (res < 0) if (res < 0)
return 0; return 0;
if (res) if (res)
@ -834,9 +824,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
} }
else { else {
/* Special-case __class__ */ /* Special-case __class__ */
if (!GET_IDENTIFIER(__class__)) if (PySet_Add(newbound, &_Py_ID(__class__)) < 0)
goto error;
if (PySet_Add(newbound, __class__) < 0)
goto error; goto error;
} }
@ -1610,13 +1598,11 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
VISIT(st, expr, e->v.UnaryOp.operand); VISIT(st, expr, e->v.UnaryOp.operand);
break; break;
case Lambda_kind: { case Lambda_kind: {
if (!GET_IDENTIFIER(lambda))
VISIT_QUIT(st, 0);
if (e->v.Lambda.args->defaults) if (e->v.Lambda.args->defaults)
VISIT_SEQ(st, expr, e->v.Lambda.args->defaults); VISIT_SEQ(st, expr, e->v.Lambda.args->defaults);
if (e->v.Lambda.args->kw_defaults) if (e->v.Lambda.args->kw_defaults)
VISIT_SEQ_WITH_NULL(st, expr, e->v.Lambda.args->kw_defaults); VISIT_SEQ_WITH_NULL(st, expr, e->v.Lambda.args->kw_defaults);
if (!symtable_enter_block(st, lambda, if (!symtable_enter_block(st, &_Py_ID(lambda),
FunctionBlock, (void *)e, FunctionBlock, (void *)e,
e->lineno, e->col_offset, e->lineno, e->col_offset,
e->end_lineno, e->end_col_offset)) e->end_lineno, e->end_col_offset))
@ -1730,8 +1716,7 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
if (e->v.Name.ctx == Load && if (e->v.Name.ctx == Load &&
st->st_cur->ste_type == FunctionBlock && st->st_cur->ste_type == FunctionBlock &&
_PyUnicode_EqualToASCIIString(e->v.Name.id, "super")) { _PyUnicode_EqualToASCIIString(e->v.Name.id, "super")) {
if (!GET_IDENTIFIER(__class__) || if (!symtable_add_def(st, &_Py_ID(__class__), USE, LOCATION(e)))
!symtable_add_def(st, __class__, USE, LOCATION(e)))
VISIT_QUIT(st, 0); VISIT_QUIT(st, 0);
} }
break; break;
@ -1832,7 +1817,7 @@ symtable_visit_annotation(struct symtable *st, expr_ty annotation)
{ {
int future_annotations = st->st_future->ff_features & CO_FUTURE_ANNOTATIONS; int future_annotations = st->st_future->ff_features & CO_FUTURE_ANNOTATIONS;
if (future_annotations && if (future_annotations &&
!symtable_enter_block(st, GET_IDENTIFIER(_annotation), AnnotationBlock, !symtable_enter_block(st, &_Py_ID(_annotation), AnnotationBlock,
(void *)annotation, annotation->lineno, (void *)annotation, annotation->lineno,
annotation->col_offset, annotation->end_lineno, annotation->col_offset, annotation->end_lineno,
annotation->end_col_offset)) { annotation->end_col_offset)) {
@ -1867,7 +1852,7 @@ symtable_visit_annotations(struct symtable *st, stmt_ty o, arguments_ty a, expr_
{ {
int future_annotations = st->st_future->ff_features & CO_FUTURE_ANNOTATIONS; int future_annotations = st->st_future->ff_features & CO_FUTURE_ANNOTATIONS;
if (future_annotations && if (future_annotations &&
!symtable_enter_block(st, GET_IDENTIFIER(_annotation), AnnotationBlock, !symtable_enter_block(st, &_Py_ID(_annotation), AnnotationBlock,
(void *)o, o->lineno, o->col_offset, o->end_lineno, (void *)o, o->lineno, o->col_offset, o->end_lineno,
o->end_col_offset)) { o->end_col_offset)) {
VISIT_QUIT(st, 0); VISIT_QUIT(st, 0);
@ -2085,7 +2070,7 @@ symtable_handle_comprehension(struct symtable *st, expr_ty e,
static int static int
symtable_visit_genexp(struct symtable *st, expr_ty e) symtable_visit_genexp(struct symtable *st, expr_ty e)
{ {
return symtable_handle_comprehension(st, e, GET_IDENTIFIER(genexpr), return symtable_handle_comprehension(st, e, &_Py_ID(genexpr),
e->v.GeneratorExp.generators, e->v.GeneratorExp.generators,
e->v.GeneratorExp.elt, NULL); e->v.GeneratorExp.elt, NULL);
} }
@ -2093,7 +2078,7 @@ symtable_visit_genexp(struct symtable *st, expr_ty e)
static int static int
symtable_visit_listcomp(struct symtable *st, expr_ty e) symtable_visit_listcomp(struct symtable *st, expr_ty e)
{ {
return symtable_handle_comprehension(st, e, GET_IDENTIFIER(listcomp), return symtable_handle_comprehension(st, e, &_Py_ID(listcomp),
e->v.ListComp.generators, e->v.ListComp.generators,
e->v.ListComp.elt, NULL); e->v.ListComp.elt, NULL);
} }
@ -2101,7 +2086,7 @@ symtable_visit_listcomp(struct symtable *st, expr_ty e)
static int static int
symtable_visit_setcomp(struct symtable *st, expr_ty e) symtable_visit_setcomp(struct symtable *st, expr_ty e)
{ {
return symtable_handle_comprehension(st, e, GET_IDENTIFIER(setcomp), return symtable_handle_comprehension(st, e, &_Py_ID(setcomp),
e->v.SetComp.generators, e->v.SetComp.generators,
e->v.SetComp.elt, NULL); e->v.SetComp.elt, NULL);
} }
@ -2109,7 +2094,7 @@ symtable_visit_setcomp(struct symtable *st, expr_ty e)
static int static int
symtable_visit_dictcomp(struct symtable *st, expr_ty e) symtable_visit_dictcomp(struct symtable *st, expr_ty e)
{ {
return symtable_handle_comprehension(st, e, GET_IDENTIFIER(dictcomp), return symtable_handle_comprehension(st, e, &_Py_ID(dictcomp),
e->v.DictComp.generators, e->v.DictComp.generators,
e->v.DictComp.key, e->v.DictComp.key,
e->v.DictComp.value); e->v.DictComp.value);
@ -2173,16 +2158,3 @@ _Py_SymtableStringObjectFlags(const char *str, PyObject *filename,
_PyArena_Free(arena); _PyArena_Free(arena);
return st; return st;
} }
void
_PySymtable_Fini(void)
{
Py_CLEAR(top);
Py_CLEAR(lambda);
Py_CLEAR(genexpr);
Py_CLEAR(listcomp);
Py_CLEAR(setcomp);
Py_CLEAR(dictcomp);
Py_CLEAR(__class__);
Py_CLEAR(_annotation);
}

View file

@ -706,7 +706,6 @@ sys_displayhook(PyObject *module, PyObject *o)
{ {
PyObject *outf; PyObject *outf;
PyObject *builtins; PyObject *builtins;
static PyObject *newline = NULL;
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
builtins = PyImport_GetModule(&_Py_ID(builtins)); builtins = PyImport_GetModule(&_Py_ID(builtins));
@ -747,12 +746,8 @@ sys_displayhook(PyObject *module, PyObject *o)
return NULL; return NULL;
} }
} }
if (newline == NULL) { _Py_DECLARE_STR(newline, "\n");
newline = PyUnicode_FromString("\n"); if (PyFile_WriteObject(&_Py_STR(newline), outf, Py_PRINT_RAW) != 0)
if (newline == NULL)
return NULL;
}
if (PyFile_WriteObject(newline, outf, Py_PRINT_RAW) != 0)
return NULL; return NULL;
if (PyObject_SetAttr(builtins, &_Py_ID(_), o) != 0) if (PyObject_SetAttr(builtins, &_Py_ID(_), o) != 0)
return NULL; return NULL;
@ -946,30 +941,18 @@ sys_intern_impl(PyObject *module, PyObject *s)
/* /*
* Cached interned string objects used for calling the profile and * Cached interned string objects used for calling the profile and
* trace functions. Initialized by trace_init(). * trace functions.
*/ */
static PyObject *whatstrings[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; static PyObject *whatstrings[8] = {
&_Py_ID(call),
static int &_Py_ID(exception),
trace_init(void) &_Py_ID(line),
{ &_Py_ID(return),
static const char * const whatnames[8] = { &_Py_ID(c_call),
"call", "exception", "line", "return", &_Py_ID(c_exception),
"c_call", "c_exception", "c_return", &_Py_ID(c_return),
"opcode" &_Py_ID(opcode),
}; };
PyObject *name;
int i;
for (i = 0; i < 8; ++i) {
if (whatstrings[i] == NULL) {
name = PyUnicode_InternFromString(whatnames[i]);
if (name == NULL)
return -1;
whatstrings[i] = name;
}
}
return 0;
}
static PyObject * static PyObject *
@ -1050,10 +1033,6 @@ trace_trampoline(PyObject *self, PyFrameObject *frame,
static PyObject * static PyObject *
sys_settrace(PyObject *self, PyObject *args) sys_settrace(PyObject *self, PyObject *args)
{ {
if (trace_init() == -1) {
return NULL;
}
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
if (args == Py_None) { if (args == Py_None) {
if (_PyEval_SetTrace(tstate, NULL, NULL) < 0) { if (_PyEval_SetTrace(tstate, NULL, NULL) < 0) {
@ -1099,10 +1078,6 @@ sys_gettrace_impl(PyObject *module)
static PyObject * static PyObject *
sys_setprofile(PyObject *self, PyObject *args) sys_setprofile(PyObject *self, PyObject *args)
{ {
if (trace_init() == -1) {
return NULL;
}
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
if (args == Py_None) { if (args == Py_None) {
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) { if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) {

View file

@ -280,66 +280,8 @@ Objects/sliceobject.c - _Py_EllipsisObject -
# cached - initialized once # cached - initialized once
# manually cached PyUnicodeObject # manually cached PyUnicodeObject
Objects/boolobject.c - false_str -
Objects/boolobject.c - true_str -
Objects/classobject.c method_get_doc docstr -
Objects/classobject.c instancemethod_get_doc docstr -
Objects/codeobject.c PyCode_NewEmpty emptystring -
Objects/exceptions.c _check_for_legacy_statements print_prefix -
Objects/exceptions.c _check_for_legacy_statements exec_prefix -
Objects/funcobject.c PyFunction_NewWithQualName __name__ -
Objects/listobject.c - indexerr -
Objects/typeobject.c object___reduce_ex___impl objreduce -
# XXX This should have been found by the analyzer but wasn't:
Python/_warnings.c is_internal_frame bootstrap_string -
# XXX This should have been found by the analyzer but wasn't:
Python/_warnings.c is_internal_frame importlib_string -
# XXX This should have been found by the analyzer but wasn't:
Python/ast_unparse.c - _str_close_br -
# XXX This should have been found by the analyzer but wasn't:
Python/ast_unparse.c - _str_dbl_close_br -
# XXX This should have been found by the analyzer but wasn't:
Python/ast_unparse.c - _str_dbl_open_br -
# XXX This should have been found by the analyzer but wasn't:
Python/ast_unparse.c - _str_inf -
# XXX This should have been found by the analyzer but wasn't:
Python/ast_unparse.c - _str_open_br -
# XXX This should have been found by the analyzer but wasn't: # XXX This should have been found by the analyzer but wasn't:
Python/ast_unparse.c - _str_replace_inf - Python/ast_unparse.c - _str_replace_inf -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c - __annotations__ -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c - __doc__ -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c compiler_dictcomp name -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c compiler_from_import empty_string -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c compiler_genexp name -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c compiler_lambda name -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c compiler_listcomp name -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c compiler_setcomp name -
# XXX This should have been found by the analyzer but wasn't:
Python/compile.c compiler_visit_annotations return_str -
# XXX This should have been found by the analyzer but wasn't:
Python/import.c PyImport_Import builtins_str -
# XXX This should have been found by the analyzer but wasn't:
Python/import.c PyImport_Import import_str -
Python/symtable.c - __class__ -
Python/symtable.c - _annotation -
Python/symtable.c - dictcomp -
Python/symtable.c - genexpr -
Python/symtable.c - lambda -
Python/symtable.c - listcomp -
Python/symtable.c - setcomp -
Python/symtable.c - top -
# XXX This should have been found by the analyzer but wasn't:
Python/sysmodule.c - whatstrings -
# XXX This should have been found by the analyzer but wasn't:
Python/sysmodule.c sys_displayhook newline -
# _PyArg_Parser (holds tuple of strings) # _PyArg_Parser (holds tuple of strings)
Objects/clinic/bytearrayobject.c.h bytearray___init__ _parser - Objects/clinic/bytearrayobject.c.h bytearray___init__ _parser -
@ -402,6 +344,7 @@ Objects/typeobject.c - slotdefs -
# other # other
Objects/typeobject.c - method_cache - Objects/typeobject.c - method_cache -
Objects/typeobject.c object___reduce_ex___impl objreduce -
Objects/unicodeobject.c - _string_module - Objects/unicodeobject.c - _string_module -
Objects/unicodeobject.c - interned - Objects/unicodeobject.c - interned -
Objects/unicodeobject.c - static_strings - Objects/unicodeobject.c - static_strings -
@ -666,37 +609,6 @@ Modules/signalmodule.c - ItimerError -
#----------------------- #-----------------------
# cached - initialized once # cached - initialized once
# manually cached PyUnicodeOjbect
Modules/_io/_iomodule.c - _PyIO_str_close -
Modules/_io/_iomodule.c - _PyIO_str_closed -
Modules/_io/_iomodule.c - _PyIO_str_decode -
Modules/_io/_iomodule.c - _PyIO_str_encode -
Modules/_io/_iomodule.c - _PyIO_str_fileno -
Modules/_io/_iomodule.c - _PyIO_str_flush -
Modules/_io/_iomodule.c - _PyIO_str_getstate -
Modules/_io/_iomodule.c - _PyIO_str_isatty -
Modules/_io/_iomodule.c - _PyIO_str_locale -
Modules/_io/_iomodule.c - _PyIO_str_newlines -
Modules/_io/_iomodule.c - _PyIO_str_nl -
Modules/_io/_iomodule.c - _PyIO_str_peek -
Modules/_io/_iomodule.c - _PyIO_str_read -
Modules/_io/_iomodule.c - _PyIO_str_read1 -
Modules/_io/_iomodule.c - _PyIO_str_readable -
Modules/_io/_iomodule.c - _PyIO_str_readall -
Modules/_io/_iomodule.c - _PyIO_str_readinto -
Modules/_io/_iomodule.c - _PyIO_str_readline -
Modules/_io/_iomodule.c - _PyIO_str_reset -
Modules/_io/_iomodule.c - _PyIO_str_seek -
Modules/_io/_iomodule.c - _PyIO_str_seekable -
Modules/_io/_iomodule.c - _PyIO_str_setstate -
Modules/_io/_iomodule.c - _PyIO_str_tell -
Modules/_io/_iomodule.c - _PyIO_str_truncate -
Modules/_io/_iomodule.c - _PyIO_str_writable -
Modules/_io/_iomodule.c - _PyIO_str_write -
Modules/_io/_iomodule.c - _PyIO_empty_str -
Modules/_threadmodule.c - str_dict -
Modules/_tracemalloc.c - unknown_filename -
# _PyArg_Parser # _PyArg_Parser
Modules/clinic/_codecsmodule.c.h _codecs_decode _parser - Modules/clinic/_codecsmodule.c.h _codecs_decode _parser -
Modules/clinic/_codecsmodule.c.h _codecs_encode _parser - Modules/clinic/_codecsmodule.c.h _codecs_encode _parser -

Can't render this file because it has a wrong number of fields in line 4.

View file

@ -1517,3 +1517,4 @@ Python/pylifecycle.c - _TARGET_LOCALES -
Python/specialize.c - adaptive_opcodes - Python/specialize.c - adaptive_opcodes -
Python/specialize.c - cache_requirements - Python/specialize.c - cache_requirements -
Python/specialize.c - compare_masks - Python/specialize.c - compare_masks -
Python/sysmodule.c - whatstrings -

Can't render this file because it has a wrong number of fields in line 4.