]> granicus.if.org Git - python/commitdiff
Avoid calling functions with an empty string as format string
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 6 Sep 2016 01:16:01 +0000 (18:16 -0700)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 6 Sep 2016 01:16:01 +0000 (18:16 -0700)
Directly pass NULL rather than an empty string.

13 files changed:
Modules/_cursesmodule.c
Modules/_elementtree.c
Modules/_sqlite/connection.c
Modules/_sqlite/cursor.c
Modules/_sqlite/module.c
Modules/_testcapimodule.c
Modules/faulthandler.c
Objects/genobject.c
Objects/weakrefobject.c
Python/bltinmodule.c
Python/pylifecycle.c
Python/pythonrun.c
Python/traceback.c

index 960752cce373d65673d8b7884b4d7dc455a7cb60..a48735f51fd893392a6bdc449ff2a04d3abceb12 100644 (file)
@@ -2306,7 +2306,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
         goto error;
     }
 
-    data = _PyObject_CallMethodId(stream, &PyId_read, "");
+    data = _PyObject_CallMethodId(stream, &PyId_read, NULL);
     if (data == NULL)
         goto error;
     if (!PyBytes_Check(data)) {
index 721293aabef1ea8496020a1d91e1a04d8a7348b1..39eba7c8250de9d3e8a0e24e9ca6e90dc3935147 100644 (file)
@@ -3399,7 +3399,7 @@ _elementtree_XMLParser_close_impl(XMLParserObject *self)
     }
     else if (self->handle_close) {
         Py_DECREF(res);
-        return PyObject_CallFunction(self->handle_close, "");
+        return _PyObject_CallNoArg(self->handle_close);
     }
     else {
         return res;
index 409fa74f16647e1b71d09940487fbda05abea356..4a10ce5ad5fd1f40fe349dc02db79e1f41091aca 100644 (file)
@@ -672,7 +672,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
     aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
 
     if (*aggregate_instance == 0) {
-        *aggregate_instance = PyObject_CallFunction(aggregate_class, "");
+        *aggregate_instance = PyObject_CallFunction(aggregate_class, NULL);
 
         if (PyErr_Occurred()) {
             *aggregate_instance = 0;
@@ -744,7 +744,7 @@ void _pysqlite_final_callback(sqlite3_context* context)
     PyErr_Fetch(&exception, &value, &tb);
     restore = 1;
 
-    function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, "");
+    function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, NULL);
 
     Py_DECREF(*aggregate_instance);
 
@@ -960,7 +960,7 @@ static int _progress_handler(void* user_arg)
 
     gilstate = PyGILState_Ensure();
 #endif
-    ret = PyObject_CallFunction((PyObject*)user_arg, "");
+    ret = PyObject_CallFunction((PyObject*)user_arg, NULL);
 
     if (!ret) {
         if (_enable_callback_tracebacks) {
@@ -1291,7 +1291,7 @@ PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args)
     PyObject* result = 0;
     PyObject* method = 0;
 
-    cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
+    cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
     if (!cursor) {
         goto error;
     }
@@ -1320,7 +1320,7 @@ PyObject* pysqlite_connection_executemany(pysqlite_Connection* self, PyObject* a
     PyObject* result = 0;
     PyObject* method = 0;
 
-    cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
+    cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
     if (!cursor) {
         goto error;
     }
@@ -1349,7 +1349,7 @@ PyObject* pysqlite_connection_executescript(pysqlite_Connection* self, PyObject*
     PyObject* result = 0;
     PyObject* method = 0;
 
-    cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
+    cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
     if (!cursor) {
         goto error;
     }
@@ -1519,7 +1519,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
         goto finally;
     }
 
-    uppercase_name = _PyObject_CallMethodId(name, &PyId_upper, "");
+    uppercase_name = _PyObject_CallMethodId(name, &PyId_upper, NULL);
     if (!uppercase_name) {
         goto finally;
     }
@@ -1611,7 +1611,7 @@ pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args)
         method_name = "rollback";
     }
 
-    result = PyObject_CallMethod((PyObject*)self, method_name, "");
+    result = PyObject_CallMethod((PyObject*)self, method_name, NULL);
     if (!result) {
         return NULL;
     }
index 98eb9616e5d3a6798e93a45d3f5443c1d0bd4c74..e2c7a3469a3bbb7b823c558bad9a8c2ee26c97e0 100644 (file)
@@ -143,7 +143,7 @@ PyObject* _pysqlite_get_converter(PyObject* key)
     PyObject* retval;
     _Py_IDENTIFIER(upper);
 
-    upcase_key = _PyObject_CallMethodId(key, &PyId_upper, "");
+    upcase_key = _PyObject_CallMethodId(key, &PyId_upper, NULL);
     if (!upcase_key) {
         return NULL;
     }
index 7cd6d2abebb3d7c4bedc5436ec9aaf17d3fb7816..cc45331ab55d1650fa585bccad91e81057795270 100644 (file)
@@ -192,7 +192,7 @@ static PyObject* module_register_converter(PyObject* self, PyObject* args)
     }
 
     /* convert the name to upper case */
-    name = _PyObject_CallMethodId(orig_name, &PyId_upper, "");
+    name = _PyObject_CallMethodId(orig_name, &PyId_upper, NULL);
     if (!name) {
         goto error;
     }
index 7b6c2c157990f708755b24b709f3c4dda6fa3b01..2fb5a14c5f78cd1aaff0dbe548e93e4de2e55224 100644 (file)
@@ -2137,7 +2137,7 @@ _make_call(void *callable)
     PyObject *rc;
     int success;
     PyGILState_STATE s = PyGILState_Ensure();
-    rc = PyObject_CallFunction((PyObject *)callable, "");
+    rc = _PyObject_CallNoArg((PyObject *)callable);
     success = (rc != NULL);
     Py_XDECREF(rc);
     PyGILState_Release(s);
@@ -3406,7 +3406,7 @@ temporary_c_thread(void *data)
     /* Allocate a Python thread state for this thread */
     state = PyGILState_Ensure();
 
-    res = PyObject_CallFunction(test_c_thread->callback, "", NULL);
+    res = _PyObject_CallNoArg(test_c_thread->callback);
     Py_CLEAR(test_c_thread->callback);
 
     if (res == NULL) {
index d6322d0f3f1b8847100113981d6b9f494e7dd6f2..8969b4ce5c2df9b5c55fe944496c1a71d091ccd1 100644 (file)
@@ -168,7 +168,7 @@ faulthandler_get_fileno(PyObject **file_ptr)
         return fd;
     }
 
-    result = _PyObject_CallMethodId(file, &PyId_fileno, "");
+    result = _PyObject_CallMethodId(file, &PyId_fileno, NULL);
     if (result == NULL)
         return -1;
 
@@ -186,7 +186,7 @@ faulthandler_get_fileno(PyObject **file_ptr)
         return -1;
     }
 
-    result = _PyObject_CallMethodId(file, &PyId_flush, "");
+    result = _PyObject_CallMethodId(file, &PyId_flush, NULL);
     if (result != NULL)
         Py_DECREF(result);
     else {
@@ -1290,7 +1290,7 @@ faulthandler_env_options(void)
     if (module == NULL) {
         return -1;
     }
-    res = _PyObject_CallMethodId(module, &PyId_enable, "");
+    res = _PyObject_CallMethodId(module, &PyId_enable, NULL);
     Py_DECREF(module);
     if (res == NULL)
         return -1;
index f4c5b47b8a1d2bbb3bfca92bd94b115828d89eb8..104d90b3e6c7fa743045d6e4bb9b9e7303a82cb3 100644 (file)
@@ -261,7 +261,7 @@ gen_close_iter(PyObject *yf)
                 PyErr_WriteUnraisable(yf);
             PyErr_Clear();
         } else {
-            retval = PyObject_CallFunction(meth, "");
+            retval = _PyObject_CallNoArg(meth);
             Py_DECREF(meth);
             if (retval == NULL)
                 return -1;
index f75b1e83a8cec650e06a848349aa6f0e1461b0a6..ab6b23525552b83b2f8a51c633d0694eb155dda3 100644 (file)
@@ -453,7 +453,7 @@ proxy_checkref(PyWeakReference *proxy)
     method(PyObject *proxy) { \
             _Py_IDENTIFIER(special); \
             UNWRAP(proxy); \
-                return _PyObject_CallMethodId(proxy, &PyId_##special, ""); \
+                return _PyObject_CallMethodId(proxy, &PyId_##special, NULL); \
         }
 
 
index 07d59caba19a91ece065a9e98dd74b007477d81d..be145609ddd94e352f293302cdc1a80bc9559faa 100644 (file)
@@ -1784,7 +1784,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
         if (do_flush == -1)
             return NULL;
         else if (do_flush) {
-            tmp = _PyObject_CallMethodId(file, &PyId_flush, "");
+            tmp = _PyObject_CallMethodId(file, &PyId_flush, NULL);
             if (tmp == NULL)
                 return NULL;
             else
@@ -1850,7 +1850,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
     }
 
     /* First of all, flush stderr */
-    tmp = _PyObject_CallMethodId(ferr, &PyId_flush, "");
+    tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
     if (tmp == NULL)
         PyErr_Clear();
     else
@@ -1859,7 +1859,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
     /* 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_CallMethodId(fin, &PyId_fileno, "");
+    tmp = _PyObject_CallMethodId(fin, &PyId_fileno, NULL);
     if (tmp == NULL) {
         PyErr_Clear();
         tty = 0;
@@ -1872,7 +1872,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
         tty = fd == fileno(stdin) && isatty(fd);
     }
     if (tty) {
-        tmp = _PyObject_CallMethodId(fout, &PyId_fileno, "");
+        tmp = _PyObject_CallMethodId(fout, &PyId_fileno, NULL);
         if (tmp == NULL) {
             PyErr_Clear();
             tty = 0;
@@ -1907,7 +1907,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
         stdin_errors_str = _PyUnicode_AsString(stdin_errors);
         if (!stdin_encoding_str || !stdin_errors_str)
             goto _readline_errors;
-        tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
+        tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
         if (tmp == NULL)
             PyErr_Clear();
         else
@@ -1987,7 +1987,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
         if (PyFile_WriteObject(prompt, fout, Py_PRINT_RAW) != 0)
             return NULL;
     }
-    tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
+    tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
     if (tmp == NULL)
         PyErr_Clear();
     else
index 004feae7a07e4012863979f3b372b61e814f542c..18968889166714066b0fa7e2222a786b0afaad9b 100644 (file)
@@ -493,7 +493,7 @@ flush_std_files(void)
     int status = 0;
 
     if (fout != NULL && fout != Py_None && !file_is_closed(fout)) {
-        tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
+        tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
         if (tmp == NULL) {
             PyErr_WriteUnraisable(fout);
             status = -1;
@@ -503,7 +503,7 @@ flush_std_files(void)
     }
 
     if (ferr != NULL && ferr != Py_None && !file_is_closed(ferr)) {
-        tmp = _PyObject_CallMethodId(ferr, &PyId_flush, "");
+        tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
         if (tmp == NULL) {
             PyErr_Clear();
             status = -1;
@@ -1072,7 +1072,7 @@ create_stdio(PyObject* io,
     text = PyUnicode_FromString(name);
     if (text == NULL || _PyObject_SetAttrId(raw, &PyId_name, text) < 0)
         goto error;
-    res = _PyObject_CallMethodId(raw, &PyId_isatty, "");
+    res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
     if (res == NULL)
         goto error;
     isatty = PyObject_IsTrue(res);
@@ -1343,7 +1343,7 @@ _Py_FatalError_PrintExc(int fd)
     Py_XDECREF(tb);
 
     /* sys.stderr may be buffered: call sys.stderr.flush() */
-    res = _PyObject_CallMethodId(ferr, &PyId_flush, "");
+    res = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
     if (res == NULL)
         PyErr_Clear();
     else
@@ -1453,7 +1453,7 @@ wait_for_thread_shutdown(void)
         PyErr_Clear();
         return;
     }
-    result = _PyObject_CallMethodId(threading, &PyId__shutdown, "");
+    result = _PyObject_CallMethodId(threading, &PyId__shutdown, NULL);
     if (result == NULL) {
         PyErr_WriteUnraisable(threading);
     }
index 3fb6f15dd7ccf45ef58e670947e0f626ed2daa9e..1fc86c0a3e5afc3d50ed3543afa96a17b143046c 100644 (file)
@@ -950,7 +950,7 @@ flush_io(void)
 
     f = _PySys_GetObjectId(&PyId_stderr);
     if (f != NULL) {
-        r = _PyObject_CallMethodId(f, &PyId_flush, "");
+        r = _PyObject_CallMethodId(f, &PyId_flush, NULL);
         if (r)
             Py_DECREF(r);
         else
@@ -958,7 +958,7 @@ flush_io(void)
     }
     f = _PySys_GetObjectId(&PyId_stdout);
     if (f != NULL) {
-        r = _PyObject_CallMethodId(f, &PyId_flush, "");
+        r = _PyObject_CallMethodId(f, &PyId_flush, NULL);
         if (r)
             Py_DECREF(r);
         else
index b33156eaa7902d269f8b440a1456873904892ead..e8aac1bad8edda3203d1db3d2065b4c5bb08f2a1 100644 (file)
@@ -314,7 +314,7 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
     if (fob == NULL) {
         PyErr_Clear();
 
-        res = _PyObject_CallMethodId(binary, &PyId_close, "");
+        res = _PyObject_CallMethodId(binary, &PyId_close, NULL);
         Py_DECREF(binary);
         if (res)
             Py_DECREF(res);
@@ -334,7 +334,7 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
             break;
         }
     }
-    res = _PyObject_CallMethodId(fob, &PyId_close, "");
+    res = _PyObject_CallMethodId(fob, &PyId_close, NULL);
     if (res)
         Py_DECREF(res);
     else