mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #19512: add some common identifiers to only create common strings once,
instead of creating temporary Unicode string objects Add also more identifiers in pythonrun.c to avoid temporary Unicode string objets for the interactive interpreter.
This commit is contained in:
parent
bb52020d44
commit
090543736f
13 changed files with 72 additions and 49 deletions
|
@ -265,7 +265,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
|
|||
if (name == NULL) /* XXX Can an object lack a '__name__' attribute? */
|
||||
goto error;
|
||||
|
||||
f_stderr = PySys_GetObject("stderr");
|
||||
f_stderr = _PySys_GetObjectId(&_PyId_stderr);
|
||||
if (f_stderr == NULL) {
|
||||
fprintf(stderr, "lost sys.stderr\n");
|
||||
goto error;
|
||||
|
@ -562,7 +562,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
|
|||
else {
|
||||
*filename = NULL;
|
||||
if (*module != Py_None && PyUnicode_CompareWithASCIIString(*module, "__main__") == 0) {
|
||||
PyObject *argv = PySys_GetObject("argv");
|
||||
PyObject *argv = _PySys_GetObjectId(&_PyId_argv);
|
||||
/* PyList_Check() is needed because sys.argv is set to None during
|
||||
Python finalization */
|
||||
if (argv != NULL && PyList_Check(argv) && PyList_Size(argv) > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue