diff Python/bltinmodule.c @ 72835:5e33219492bc

Add API for static strings, primarily good for identifiers. Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
author Martin v. Löwis <martin@v.loewis.de>
date Sun, 09 Oct 2011 10:38:36 +0200
parents 8beaa9a37387
children 81380082d216
line wrap: on
line diff
--- a/Python/bltinmodule.c	Sun Oct 09 08:58:16 2011 +0200
+++ b/Python/bltinmodule.c	Sun Oct 09 10:38:36 2011 +0200
@@ -32,6 +32,9 @@
 int Py_HasFileSystemDefaultEncoding = 0;
 #endif
 
+_Py_identifier(fileno);
+_Py_identifier(flush);
+
 static PyObject *
 builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1567,7 +1570,7 @@
     }
 
     /* First of all, flush stderr */
-    tmp = PyObject_CallMethod(ferr, "flush", "");
+    tmp = _PyObject_CallMethodId(ferr, &PyId_flush, "");
     if (tmp == NULL)
         PyErr_Clear();
     else
@@ -1576,7 +1579,7 @@
     /* We should only use (GNU) readline if Python's sys.stdin and
        sys.stdout are the same as C's stdin and stdout, because we
        need to pass it those. */
-    tmp = PyObject_CallMethod(fin, "fileno", "");
+    tmp = _PyObject_CallMethodId(fin, &PyId_fileno, "");
     if (tmp == NULL) {
         PyErr_Clear();
         tty = 0;
@@ -1589,7 +1592,7 @@
         tty = fd == fileno(stdin) && isatty(fd);
     }
     if (tty) {
-        tmp = PyObject_CallMethod(fout, "fileno", "");
+        tmp = _PyObject_CallMethodId(fout, &PyId_fileno, "");
         if (tmp == NULL)
             PyErr_Clear();
         else {
@@ -1621,7 +1624,7 @@
             Py_DECREF(stdin_encoding);
             return NULL;
         }
-        tmp = PyObject_CallMethod(fout, "flush", "");
+        tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
         if (tmp == NULL)
             PyErr_Clear();
         else
@@ -1703,7 +1706,7 @@
         if (PyFile_WriteObject(promptarg, fout, Py_PRINT_RAW) != 0)
             return NULL;
     }
-    tmp = PyObject_CallMethod(fout, "flush", "");
+    tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
     if (tmp == NULL)
         PyErr_Clear();
     else