Skip to content

Commit 3466bde

Browse files
committed
Avoid calling functions with an empty string as format string
Directly pass NULL rather than an empty string.
1 parent ad8c83a commit 3466bde

File tree

13 files changed

+34
-34
lines changed

13 files changed

+34
-34
lines changed

Modules/_cursesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
23062306
goto error;
23072307
}
23082308

2309-
data = _PyObject_CallMethodId(stream, &PyId_read, "");
2309+
data = _PyObject_CallMethodId(stream, &PyId_read, NULL);
23102310
if (data == NULL)
23112311
goto error;
23122312
if (!PyBytes_Check(data)) {

Modules/_elementtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3399,7 +3399,7 @@ _elementtree_XMLParser_close_impl(XMLParserObject *self)
33993399
}
34003400
else if (self->handle_close) {
34013401
Py_DECREF(res);
3402-
return PyObject_CallFunction(self->handle_close, "");
3402+
return _PyObject_CallNoArg(self->handle_close);
34033403
}
34043404
else {
34053405
return res;

Modules/_sqlite/connection.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
672672
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
673673

674674
if (*aggregate_instance == 0) {
675-
*aggregate_instance = PyObject_CallFunction(aggregate_class, "");
675+
*aggregate_instance = PyObject_CallFunction(aggregate_class, NULL);
676676

677677
if (PyErr_Occurred()) {
678678
*aggregate_instance = 0;
@@ -744,7 +744,7 @@ void _pysqlite_final_callback(sqlite3_context* context)
744744
PyErr_Fetch(&exception, &value, &tb);
745745
restore = 1;
746746

747-
function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, "");
747+
function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, NULL);
748748

749749
Py_DECREF(*aggregate_instance);
750750

@@ -960,7 +960,7 @@ static int _progress_handler(void* user_arg)
960960

961961
gilstate = PyGILState_Ensure();
962962
#endif
963-
ret = PyObject_CallFunction((PyObject*)user_arg, "");
963+
ret = PyObject_CallFunction((PyObject*)user_arg, NULL);
964964

965965
if (!ret) {
966966
if (_enable_callback_tracebacks) {
@@ -1291,7 +1291,7 @@ PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args)
12911291
PyObject* result = 0;
12921292
PyObject* method = 0;
12931293

1294-
cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
1294+
cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
12951295
if (!cursor) {
12961296
goto error;
12971297
}
@@ -1320,7 +1320,7 @@ PyObject* pysqlite_connection_executemany(pysqlite_Connection* self, PyObject* a
13201320
PyObject* result = 0;
13211321
PyObject* method = 0;
13221322

1323-
cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
1323+
cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
13241324
if (!cursor) {
13251325
goto error;
13261326
}
@@ -1349,7 +1349,7 @@ PyObject* pysqlite_connection_executescript(pysqlite_Connection* self, PyObject*
13491349
PyObject* result = 0;
13501350
PyObject* method = 0;
13511351

1352-
cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
1352+
cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
13531353
if (!cursor) {
13541354
goto error;
13551355
}
@@ -1519,7 +1519,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
15191519
goto finally;
15201520
}
15211521

1522-
uppercase_name = _PyObject_CallMethodId(name, &PyId_upper, "");
1522+
uppercase_name = _PyObject_CallMethodId(name, &PyId_upper, NULL);
15231523
if (!uppercase_name) {
15241524
goto finally;
15251525
}
@@ -1611,7 +1611,7 @@ pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args)
16111611
method_name = "rollback";
16121612
}
16131613

1614-
result = PyObject_CallMethod((PyObject*)self, method_name, "");
1614+
result = PyObject_CallMethod((PyObject*)self, method_name, NULL);
16151615
if (!result) {
16161616
return NULL;
16171617
}

Modules/_sqlite/cursor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ PyObject* _pysqlite_get_converter(PyObject* key)
143143
PyObject* retval;
144144
_Py_IDENTIFIER(upper);
145145

146-
upcase_key = _PyObject_CallMethodId(key, &PyId_upper, "");
146+
upcase_key = _PyObject_CallMethodId(key, &PyId_upper, NULL);
147147
if (!upcase_key) {
148148
return NULL;
149149
}

Modules/_sqlite/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static PyObject* module_register_converter(PyObject* self, PyObject* args)
192192
}
193193

194194
/* convert the name to upper case */
195-
name = _PyObject_CallMethodId(orig_name, &PyId_upper, "");
195+
name = _PyObject_CallMethodId(orig_name, &PyId_upper, NULL);
196196
if (!name) {
197197
goto error;
198198
}

Modules/_testcapimodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ _make_call(void *callable)
21372137
PyObject *rc;
21382138
int success;
21392139
PyGILState_STATE s = PyGILState_Ensure();
2140-
rc = PyObject_CallFunction((PyObject *)callable, "");
2140+
rc = _PyObject_CallNoArg((PyObject *)callable);
21412141
success = (rc != NULL);
21422142
Py_XDECREF(rc);
21432143
PyGILState_Release(s);
@@ -3406,7 +3406,7 @@ temporary_c_thread(void *data)
34063406
/* Allocate a Python thread state for this thread */
34073407
state = PyGILState_Ensure();
34083408

3409-
res = PyObject_CallFunction(test_c_thread->callback, "", NULL);
3409+
res = _PyObject_CallNoArg(test_c_thread->callback);
34103410
Py_CLEAR(test_c_thread->callback);
34113411

34123412
if (res == NULL) {

Modules/faulthandler.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ faulthandler_get_fileno(PyObject **file_ptr)
168168
return fd;
169169
}
170170

171-
result = _PyObject_CallMethodId(file, &PyId_fileno, "");
171+
result = _PyObject_CallMethodId(file, &PyId_fileno, NULL);
172172
if (result == NULL)
173173
return -1;
174174

@@ -186,7 +186,7 @@ faulthandler_get_fileno(PyObject **file_ptr)
186186
return -1;
187187
}
188188

189-
result = _PyObject_CallMethodId(file, &PyId_flush, "");
189+
result = _PyObject_CallMethodId(file, &PyId_flush, NULL);
190190
if (result != NULL)
191191
Py_DECREF(result);
192192
else {
@@ -1290,7 +1290,7 @@ faulthandler_env_options(void)
12901290
if (module == NULL) {
12911291
return -1;
12921292
}
1293-
res = _PyObject_CallMethodId(module, &PyId_enable, "");
1293+
res = _PyObject_CallMethodId(module, &PyId_enable, NULL);
12941294
Py_DECREF(module);
12951295
if (res == NULL)
12961296
return -1;

Objects/genobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ gen_close_iter(PyObject *yf)
261261
PyErr_WriteUnraisable(yf);
262262
PyErr_Clear();
263263
} else {
264-
retval = PyObject_CallFunction(meth, "");
264+
retval = _PyObject_CallNoArg(meth);
265265
Py_DECREF(meth);
266266
if (retval == NULL)
267267
return -1;

Objects/weakrefobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ proxy_checkref(PyWeakReference *proxy)
453453
method(PyObject *proxy) { \
454454
_Py_IDENTIFIER(special); \
455455
UNWRAP(proxy); \
456-
return _PyObject_CallMethodId(proxy, &PyId_##special, ""); \
456+
return _PyObject_CallMethodId(proxy, &PyId_##special, NULL); \
457457
}
458458

459459

Python/bltinmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
17841784
if (do_flush == -1)
17851785
return NULL;
17861786
else if (do_flush) {
1787-
tmp = _PyObject_CallMethodId(file, &PyId_flush, "");
1787+
tmp = _PyObject_CallMethodId(file, &PyId_flush, NULL);
17881788
if (tmp == NULL)
17891789
return NULL;
17901790
else
@@ -1850,7 +1850,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
18501850
}
18511851

18521852
/* First of all, flush stderr */
1853-
tmp = _PyObject_CallMethodId(ferr, &PyId_flush, "");
1853+
tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
18541854
if (tmp == NULL)
18551855
PyErr_Clear();
18561856
else
@@ -1859,7 +1859,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
18591859
/* We should only use (GNU) readline if Python's sys.stdin and
18601860
sys.stdout are the same as C's stdin and stdout, because we
18611861
need to pass it those. */
1862-
tmp = _PyObject_CallMethodId(fin, &PyId_fileno, "");
1862+
tmp = _PyObject_CallMethodId(fin, &PyId_fileno, NULL);
18631863
if (tmp == NULL) {
18641864
PyErr_Clear();
18651865
tty = 0;
@@ -1872,7 +1872,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
18721872
tty = fd == fileno(stdin) && isatty(fd);
18731873
}
18741874
if (tty) {
1875-
tmp = _PyObject_CallMethodId(fout, &PyId_fileno, "");
1875+
tmp = _PyObject_CallMethodId(fout, &PyId_fileno, NULL);
18761876
if (tmp == NULL) {
18771877
PyErr_Clear();
18781878
tty = 0;
@@ -1907,7 +1907,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
19071907
stdin_errors_str = _PyUnicode_AsString(stdin_errors);
19081908
if (!stdin_encoding_str || !stdin_errors_str)
19091909
goto _readline_errors;
1910-
tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
1910+
tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
19111911
if (tmp == NULL)
19121912
PyErr_Clear();
19131913
else
@@ -1987,7 +1987,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
19871987
if (PyFile_WriteObject(prompt, fout, Py_PRINT_RAW) != 0)
19881988
return NULL;
19891989
}
1990-
tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
1990+
tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
19911991
if (tmp == NULL)
19921992
PyErr_Clear();
19931993
else

0 commit comments

Comments
 (0)