*NULL* on failure.
+.. c:function:: PyObject* _PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name)
+
+ Call a method of the Python object *obj* without arguments,
+ where the name of the method is given as a Python string object in *name*.
+
+ Return the result of the call on success, or raise an exception and return
+ *NULL* on failure.
+
+ .. versionadded:: 3.9
+
+
.. c:function:: PyObject* _PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
Call a callable Python object *callable*, using
PyObject *name, PyObject *const *args,
size_t nargsf, PyObject *kwnames);
+static inline PyObject *
+_PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
+{
+ return _PyObject_VectorcallMethod(name, &self,
+ 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+}
+
/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
as the method name. */
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
return _PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
}
+static inline PyObject *
+_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
+{
+ return _PyObject_VectorcallMethodId(name, &self,
+ 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+}
+
PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o);
/* Guess the size of object 'o' using len(o) or o.__length_hint__().
-Add :c:func:`_PyObject_VectorcallMethod` for fast calling of methods.
+Add fast functions for calling methods: :c:func:`_PyObject_VectorcallMethod`
+and :c:func:`_PyObject_CallMethodNoArgs`
return NULL;
}
- loop = _PyObject_CallMethodId(policy, &PyId_get_event_loop, NULL);
+ loop = _PyObject_CallMethodIdNoArgs(policy, &PyId_get_event_loop);
Py_DECREF(policy);
return loop;
}
}
fut->fut_loop = loop;
- res = _PyObject_CallMethodId(fut->fut_loop, &PyId_get_debug, NULL);
+ res = _PyObject_CallMethodIdNoArgs(fut->fut_loop, &PyId_get_debug);
if (res == NULL) {
return -1;
}
ENSURE_FUTURE_ALIVE(fut)
- PyObject *rinfo = _PyObject_CallMethodIdObjArgs((PyObject*)fut,
- &PyId__repr_info,
- NULL);
+ PyObject *rinfo = _PyObject_CallMethodIdNoArgs((PyObject*)fut,
+ &PyId__repr_info);
if (rinfo == NULL) {
return NULL;
}
PyObject *res;
int is_true;
- res = _PyObject_CallMethodId(
- self->task_fut_waiter, &PyId_cancel, NULL);
+ res = _PyObject_CallMethodIdNoArgs(self->task_fut_waiter, &PyId_cancel);
if (res == NULL) {
return NULL;
}
if (task->task_must_cancel) {
PyObject *r;
int is_true;
- r = _PyObject_CallMethodId(result, &PyId_cancel, NULL);
+ r = _PyObject_CallMethodIdNoArgs(result, &PyId_cancel);
if (r == NULL) {
return NULL;
}
if (task->task_must_cancel) {
PyObject *r;
int is_true;
- r = _PyObject_CallMethodId(result, &PyId_cancel, NULL);
+ r = _PyObject_CallMethodIdNoArgs(result, &PyId_cancel);
if (r == NULL) {
return NULL;
}
args = PyTuple_Pack(1, dd->default_factory);
if (args == NULL)
return NULL;
- items = _PyObject_CallMethodId((PyObject *)dd, &PyId_items, NULL);
+ items = _PyObject_CallMethodIdNoArgs((PyObject *)dd, &PyId_items);
if (items == NULL) {
Py_DECREF(args);
return NULL;
_Py_IDENTIFIER(__ctypes_from_outparam__);
v = PyTuple_GET_ITEM(callargs, i);
- v = _PyObject_CallMethodId(v, &PyId___ctypes_from_outparam__, NULL);
+ v = _PyObject_CallMethodIdNoArgs(v, &PyId___ctypes_from_outparam__);
if (v == NULL || numretvals == 1) {
Py_DECREF(callargs);
return v;
if (_Py_set_inheritable(fileno(fp), 0, NULL) < 0)
goto error;
- data = _PyObject_CallMethodId(file, &PyId_read, NULL);
+ data = _PyObject_CallMethodIdNoArgs(file, &PyId_read);
if (data == NULL)
goto error;
if (!PyBytes_Check(data)) {
if (time != NULL) {
_Py_IDENTIFIER(time);
- result = _PyObject_CallMethodId(time, &PyId_time, NULL);
+ result = _PyObject_CallMethodIdNoArgs(time, &PyId_time);
Py_DECREF(time);
}
return result;
PyObject *ratio;
assert(floatobj && PyFloat_Check(floatobj));
- ratio = _PyObject_CallMethodId(floatobj, &PyId_as_integer_ratio, NULL);
+ ratio = _PyObject_CallMethodIdNoArgs(floatobj, &PyId_as_integer_ratio);
if (ratio == NULL) {
return NULL;
}
static PyObject *
date_str(PyDateTime_Date *self)
{
- return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, NULL);
+ return _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_isoformat);
}
&format))
return NULL;
- tuple = _PyObject_CallMethodId((PyObject *)self, &PyId_timetuple, NULL);
+ tuple = _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_timetuple);
if (tuple == NULL)
return NULL;
result = wrap_strftime((PyObject *)self, format, tuple,
static PyObject *
time_str(PyDateTime_Time *self)
{
- return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, NULL);
+ return _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_isoformat);
}
static PyObject *
dbm__exit__(PyObject *self, PyObject *args)
{
_Py_IDENTIFIER(close);
- return _PyObject_CallMethodId(self, &PyId_close, NULL);
+ return _PyObject_CallMethodIdNoArgs(self, &PyId_close);
}
dbm__exit__(PyObject *self, PyObject *args)
{
_Py_IDENTIFIER(close);
- return _PyObject_CallMethodId(self, &PyId_close, NULL);
+ return _PyObject_CallMethodIdNoArgs(self, &PyId_close);
}
static PyMethodDef dbm_methods[] = {
/* buffering */
if (buffering < 0) {
- PyObject *res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
+ PyObject *res = _PyObject_CallMethodIdNoArgs(raw, &PyId_isatty);
if (res == NULL)
goto error;
isatty = PyLong_AsLong(res);
if (result != NULL) {
PyObject *exc, *val, *tb, *close_result;
PyErr_Fetch(&exc, &val, &tb);
- close_result = _PyObject_CallMethodId(result, &PyId_close, NULL);
+ close_result = _PyObject_CallMethodIdNoArgs(result, &PyId_close);
_PyErr_ChainExceptions(exc, val, tb);
Py_XDECREF(close_result);
Py_DECREF(result);
buffered_simple_flush(buffered *self, PyObject *args)
{
CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_flush, NULL);
+ return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_flush);
}
static int
}
/* flush() will most probably re-take the lock, so drop it first */
LEAVE_BUFFERED(self)
- res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
+ res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush);
if (!ENTER_BUFFERED(self))
return NULL;
if (res == NULL)
else
Py_DECREF(res);
- res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_close, NULL);
+ res = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_close);
if (self->buffer) {
PyMem_Free(self->buffer);
{
PyObject *raw, *res;
CHECK_INITIALIZED(self)
- res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
+ res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush);
if (res == NULL)
return NULL;
Py_DECREF(res);
buffered_seekable(buffered *self, PyObject *Py_UNUSED(ignored))
{
CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_seekable, NULL);
+ return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_seekable);
}
static PyObject *
buffered_readable(buffered *self, PyObject *Py_UNUSED(ignored))
{
CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_readable, NULL);
+ return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_readable);
}
static PyObject *
buffered_writable(buffered *self, PyObject *Py_UNUSED(ignored))
{
CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_writable, NULL);
+ return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_writable);
}
static PyObject *
buffered_fileno(buffered *self, PyObject *Py_UNUSED(ignored))
{
CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_fileno, NULL);
+ return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_fileno);
}
static PyObject *
buffered_isatty(buffered *self, PyObject *Py_UNUSED(ignored))
{
CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_isatty, NULL);
+ return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_isatty);
}
/* Forward decls */
{
Py_off_t n;
PyObject *res;
- res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_tell, NULL);
+ res = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_tell);
if (res == NULL)
return -1;
n = PyNumber_AsOff_t(res, PyExc_ValueError);
line = _buffered_readline(self, -1);
}
else {
- line = PyObject_CallMethodObjArgs((PyObject *)self,
- _PyIO_str_readline, NULL);
+ line = _PyObject_CallMethodNoArgs((PyObject *)self,
+ _PyIO_str_readline);
if (line && !PyBytes_Check(line)) {
PyErr_Format(PyExc_OSError,
"readline() should have returned a bytes object, "
}
/* Read until EOF or until read() would block. */
- data = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_read, NULL);
+ data = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_read);
if (data == NULL)
goto cleanup;
if (data != Py_None && !PyBytes_Check(data)) {
Py_RETURN_NONE;
}
- res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
+ res = _PyObject_CallMethodNoArgs(self, _PyIO_str_flush);
PyErr_Fetch(&exc, &val, &tb);
rc = _PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True);
finalization process. */
if (_PyObject_SetAttrId(self, &PyId__finalizing, Py_True))
PyErr_Clear();
- res = PyObject_CallMethodObjArgs((PyObject *) self, _PyIO_str_close,
- NULL);
+ res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_close);
/* Silencing I/O errors is bad, but printing spurious tracebacks is
equally as bad, and potentially more frequent (because of
shutdown issues). */
PyObject *
_PyIOBase_check_seekable(PyObject *self, PyObject *args)
{
- PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_seekable, NULL);
+ PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_seekable);
if (res == NULL)
return NULL;
if (res != Py_True) {
PyObject *
_PyIOBase_check_readable(PyObject *self, PyObject *args)
{
- PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_readable, NULL);
+ PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_readable);
if (res == NULL)
return NULL;
if (res != Py_True) {
PyObject *
_PyIOBase_check_writable(PyObject *self, PyObject *args)
{
- PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL);
+ PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_writable);
if (res == NULL)
return NULL;
if (res != Py_True) {
static PyObject *
iobase_exit(PyObject *self, PyObject *args)
{
- return PyObject_CallMethodObjArgs(self, _PyIO_str_close, NULL);
+ return _PyObject_CallMethodNoArgs(self, _PyIO_str_close);
}
/* Lower-level APIs */
static PyObject *
iobase_iternext(PyObject *self)
{
- PyObject *line = PyObject_CallMethodObjArgs(self, _PyIO_str_readline, NULL);
+ PyObject *line = _PyObject_CallMethodNoArgs(self, _PyIO_str_readline);
if (line == NULL)
return NULL;
if (n < 0) {
_Py_IDENTIFIER(readall);
- return _PyObject_CallMethodId(self, &PyId_readall, NULL);
+ return _PyObject_CallMethodIdNoArgs(self, &PyId_readall);
}
/* TODO: allocate a bytes object directly instead and manually construct
}
else {
/* XXX is subclassing StringIO really supported? */
- line = PyObject_CallMethodObjArgs((PyObject *)self,
- _PyIO_str_readline, NULL);
+ line = _PyObject_CallMethodNoArgs((PyObject *)self,
+ _PyIO_str_readline);
if (line && !PyUnicode_Check(line)) {
PyErr_Format(PyExc_OSError,
"readline() should have returned a str object, "
unsigned long long flag;
if (self->decoder != Py_None) {
- PyObject *state = PyObject_CallMethodObjArgs(self->decoder,
- _PyIO_str_getstate, NULL);
+ PyObject *state = _PyObject_CallMethodNoArgs(self->decoder,
+ _PyIO_str_getstate);
if (state == NULL)
return NULL;
if (!PyTuple_Check(state)) {
self->seennl = 0;
self->pendingcr = 0;
if (self->decoder != Py_None)
- return PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_reset, NULL);
+ return _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset);
else
Py_RETURN_NONE;
}
PyObject *res;
int r;
- res = _PyObject_CallMethodId(self->buffer, &PyId_readable, NULL);
+ res = _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_readable);
if (res == NULL)
return -1;
PyObject *res;
int r;
- res = _PyObject_CallMethodId(self->buffer, &PyId_writable, NULL);
+ res = _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_writable);
if (res == NULL)
return -1;
self->encoding_start_of_stream = 1;
- PyObject *cookieObj = PyObject_CallMethodObjArgs(
- self->buffer, _PyIO_str_tell, NULL);
+ PyObject *cookieObj = _PyObject_CallMethodNoArgs(
+ self->buffer, _PyIO_str_tell);
if (cookieObj == NULL) {
return -1;
}
state = IO_STATE();
if (state == NULL)
goto error;
- fileno = _PyObject_CallMethodId(buffer, &PyId_fileno, NULL);
+ fileno = _PyObject_CallMethodIdNoArgs(buffer, &PyId_fileno);
/* Ignore only AttributeError and UnsupportedOperation */
if (fileno == NULL) {
if (PyErr_ExceptionMatches(PyExc_AttributeError) ||
}
}
- res = _PyObject_CallMethodId(buffer, &PyId_seekable, NULL);
+ res = _PyObject_CallMethodIdNoArgs(buffer, &PyId_seekable);
if (res == NULL)
goto error;
r = PyObject_IsTrue(res);
return NULL;
}
- PyObject *res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
+ PyObject *res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush);
if (res == NULL) {
return NULL;
}
{
PyObject *buffer, *res;
CHECK_ATTACHED(self);
- res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
+ res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush);
if (res == NULL)
return NULL;
Py_DECREF(res);
}
if (needflush) {
- ret = PyObject_CallMethodObjArgs(self->buffer, _PyIO_str_flush, NULL);
+ ret = _PyObject_CallMethodNoArgs(self->buffer, _PyIO_str_flush);
if (ret == NULL)
return NULL;
Py_DECREF(ret);
Py_CLEAR(self->snapshot);
if (self->decoder) {
- ret = _PyObject_CallMethodId(self->decoder, &PyId_reset, NULL);
+ ret = _PyObject_CallMethodIdNoArgs(self->decoder, &PyId_reset);
if (ret == NULL)
return NULL;
Py_DECREF(ret);
/* To prepare for tell(), we need to snapshot a point in the file
* where the decoder's input buffer is empty.
*/
-
- PyObject *state = PyObject_CallMethodObjArgs(self->decoder,
- _PyIO_str_getstate, NULL);
+ PyObject *state = _PyObject_CallMethodNoArgs(self->decoder,
+ _PyIO_str_getstate);
if (state == NULL)
return -1;
/* Given this, we know there was a valid snapshot point
if (n < 0) {
/* Read everything */
- PyObject *bytes = _PyObject_CallMethodId(self->buffer, &PyId_read, NULL);
+ PyObject *bytes = _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_read);
PyObject *decoded;
if (bytes == NULL)
goto fail;
utf-16, that we are expecting a BOM).
*/
if (cookie->start_pos == 0 && cookie->dec_flags == 0)
- res = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_reset, NULL);
+ res = _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset);
else
res = _PyObject_CallMethodId(self->decoder, &PyId_setstate,
"((yi))", "", cookie->dec_flags);
{
PyObject *res;
if (start_of_stream) {
- res = PyObject_CallMethodObjArgs(self->encoder, _PyIO_str_reset, NULL);
+ res = _PyObject_CallMethodNoArgs(self->encoder, _PyIO_str_reset);
self->encoding_start_of_stream = 1;
}
else {
* sync the underlying buffer with the current position.
*/
Py_DECREF(cookieObj);
- cookieObj = _PyObject_CallMethodId((PyObject *)self, &PyId_tell, NULL);
+ cookieObj = _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_tell);
if (cookieObj == NULL)
goto fail;
break;
goto fail;
}
- res = _PyObject_CallMethodId((PyObject *)self, &PyId_flush, NULL);
+ res = _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_flush);
if (res == NULL)
goto fail;
Py_DECREF(res);
textiowrapper_set_decoded_chars(self, NULL);
Py_CLEAR(self->snapshot);
if (self->decoder) {
- res = _PyObject_CallMethodId(self->decoder, &PyId_reset, NULL);
+ res = _PyObject_CallMethodIdNoArgs(self->decoder, &PyId_reset);
if (res == NULL)
goto fail;
Py_DECREF(res);
goto fail;
}
- res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
+ res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush);
if (res == NULL)
goto fail;
Py_DECREF(res);
if (_textiowrapper_writeflush(self) < 0)
return NULL;
- res = _PyObject_CallMethodId((PyObject *)self, &PyId_flush, NULL);
+ res = _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_flush);
if (res == NULL)
goto fail;
Py_DECREF(res);
- posobj = _PyObject_CallMethodId(self->buffer, &PyId_tell, NULL);
+ posobj = _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_tell);
if (posobj == NULL)
goto fail;
chars_to_skip = self->decoded_chars_used;
/* Decoder state will be restored at the end */
- saved_state = PyObject_CallMethodObjArgs(self->decoder,
- _PyIO_str_getstate, NULL);
+ saved_state = _PyObject_CallMethodNoArgs(self->decoder,
+ _PyIO_str_getstate);
if (saved_state == NULL)
goto fail;
#define DECODER_GETSTATE() do { \
PyObject *dec_buffer; \
- PyObject *_state = PyObject_CallMethodObjArgs(self->decoder, \
- _PyIO_str_getstate, NULL); \
+ PyObject *_state = _PyObject_CallMethodNoArgs(self->decoder, \
+ _PyIO_str_getstate); \
if (_state == NULL) \
goto fail; \
if (!PyTuple_Check(_state)) { \
CHECK_ATTACHED(self)
- res = PyObject_CallMethodObjArgs((PyObject *) self, _PyIO_str_flush, NULL);
+ res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush);
if (res == NULL)
return NULL;
Py_DECREF(res);
/*[clinic end generated code: output=21490a4c3da13e6c input=c488ca83d0069f9b]*/
{
CHECK_ATTACHED(self);
- return _PyObject_CallMethodId(self->buffer, &PyId_fileno, NULL);
+ return _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_fileno);
}
/*[clinic input]
/*[clinic end generated code: output=ab223dbbcffc0f00 input=8b005ca06e1fca13]*/
{
CHECK_ATTACHED(self);
- return _PyObject_CallMethodId(self->buffer, &PyId_seekable, NULL);
+ return _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_seekable);
}
/*[clinic input]
/*[clinic end generated code: output=72ff7ba289a8a91b input=0704ea7e01b0d3eb]*/
{
CHECK_ATTACHED(self);
- return _PyObject_CallMethodId(self->buffer, &PyId_readable, NULL);
+ return _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_readable);
}
/*[clinic input]
/*[clinic end generated code: output=a728c71790d03200 input=c41740bc9d8636e8]*/
{
CHECK_ATTACHED(self);
- return _PyObject_CallMethodId(self->buffer, &PyId_writable, NULL);
+ return _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_writable);
}
/*[clinic input]
/*[clinic end generated code: output=12be1a35bace882e input=fb68d9f2c99bbfff]*/
{
CHECK_ATTACHED(self);
- return _PyObject_CallMethodId(self->buffer, &PyId_isatty, NULL);
+ return _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_isatty);
}
/*[clinic input]
self->telling = self->seekable;
if (_textiowrapper_writeflush(self) < 0)
return NULL;
- return _PyObject_CallMethodId(self->buffer, &PyId_flush, NULL);
+ return _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_flush);
}
/*[clinic input]
else
PyErr_Clear();
}
- res = _PyObject_CallMethodId((PyObject *)self, &PyId_flush, NULL);
+ res = _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_flush);
if (res == NULL)
PyErr_Fetch(&exc, &val, &tb);
else
Py_DECREF(res);
- res = _PyObject_CallMethodId(self->buffer, &PyId_close, NULL);
+ res = _PyObject_CallMethodIdNoArgs(self->buffer, &PyId_close);
if (exc != NULL) {
_PyErr_ChainExceptions(exc, val, tb);
Py_CLEAR(res);
line = _textiowrapper_readline(self, -1);
}
else {
- line = PyObject_CallMethodObjArgs((PyObject *)self,
- _PyIO_str_readline, NULL);
+ line = _PyObject_CallMethodNoArgs((PyObject *)self,
+ _PyIO_str_readline);
if (line && !PyUnicode_Check(line)) {
PyErr_Format(PyExc_OSError,
"readline() should have returned a str object, "
} else {
_Py_IDENTIFIER(items);
- items = _PyObject_CallMethodId(obj, &PyId_items, NULL);
+ items = _PyObject_CallMethodIdNoArgs(obj, &PyId_items);
if (items == NULL)
goto error;
iter = PyObject_GetIter(items);
if (need_to_reenable_gc) {
PyErr_Fetch(&exctype, &val, &tb);
- result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL);
+ result = _PyObject_CallMethodIdNoArgs(gc_module, &PyId_enable);
if (exctype != NULL) {
PyErr_Restore(exctype, val, tb);
}
gc_module = PyImport_ImportModule("gc");
if (gc_module == NULL)
return NULL;
- result = _PyObject_CallMethodId(gc_module, &PyId_isenabled, NULL);
+ result = _PyObject_CallMethodIdNoArgs(gc_module, &PyId_isenabled);
if (result == NULL) {
Py_DECREF(gc_module);
return NULL;
Py_DECREF(gc_module);
return NULL;
}
- result = _PyObject_CallMethodId(gc_module, &PyId_disable, NULL);
+ result = _PyObject_CallMethodIdNoArgs(gc_module, &PyId_disable);
if (result == NULL) {
Py_DECREF(gc_module);
return NULL;
PyErr_Fetch(&exception, &value, &tb);
restore = 1;
- function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, NULL);
+ function_result = _PyObject_CallMethodIdNoArgs(*aggregate_instance, &PyId_finalize);
Py_DECREF(*aggregate_instance);
PyObject* result = 0;
PyObject* method = 0;
- cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
+ cursor = _PyObject_CallMethodIdNoArgs((PyObject*)self, &PyId_cursor);
if (!cursor) {
goto error;
}
PyObject* result = 0;
PyObject* method = 0;
- cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
+ cursor = _PyObject_CallMethodIdNoArgs((PyObject*)self, &PyId_cursor);
if (!cursor) {
goto error;
}
PyObject* result = 0;
PyObject* method = 0;
- cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, NULL);
+ cursor = _PyObject_CallMethodIdNoArgs((PyObject*)self, &PyId_cursor);
if (!cursor) {
goto error;
}
if (!key) {
return NULL;
}
- upcase_key = _PyObject_CallMethodId(key, &PyId_upper, NULL);
+ upcase_key = _PyObject_CallMethodIdNoArgs(key, &PyId_upper);
Py_DECREF(key);
if (!upcase_key) {
return NULL;
}
/* convert the name to upper case */
- name = _PyObject_CallMethodId(orig_name, &PyId_upper, NULL);
+ name = _PyObject_CallMethodIdNoArgs(orig_name, &PyId_upper);
if (!name) {
goto error;
}
_PyErr_Display(file, exc_type, exc_value, exc_traceback);
/* Call file.flush() */
- PyObject *res = _PyObject_CallMethodId(file, &PyId_flush, NULL);
+ PyObject *res = _PyObject_CallMethodIdNoArgs(file, &PyId_flush);
if (!res) {
return -1;
}
return fd;
}
- result = _PyObject_CallMethodId(file, &PyId_fileno, NULL);
+ result = _PyObject_CallMethodIdNoArgs(file, &PyId_fileno);
if (result == NULL)
return -1;
return -1;
}
- result = _PyObject_CallMethodId(file, &PyId_flush, NULL);
+ result = _PyObject_CallMethodIdNoArgs(file, &PyId_flush);
if (result != NULL)
Py_DECREF(result);
else {
return -1;
}
- PyObject *res = _PyObject_CallMethodId(module, &PyId_enable, NULL);
+ PyObject *res = _PyObject_CallMethodIdNoArgs(module, &PyId_enable);
Py_DECREF(module);
if (res == NULL) {
return -1;
{
_Py_IDENTIFIER(close);
- return _PyObject_CallMethodId(self, &PyId_close, NULL);
+ return _PyObject_CallMethodIdNoArgs(self, &PyId_close);
}
#ifdef MS_WINDOWS
{
_Py_IDENTIFIER(close);
- PyObject *ret = _PyObject_CallMethodId(self, &PyId_close, NULL);
+ PyObject *ret = _PyObject_CallMethodIdNoArgs(self, &PyId_close);
if (!ret)
return NULL;
Py_DECREF(ret);
{
_Py_IDENTIFIER(close);
- return _PyObject_CallMethodId((PyObject *)self, &PyId_close, NULL);
+ return _PyObject_CallMethodIdNoArgs((PyObject *)self, &PyId_close);
}
static PyGetSetDef pyepoll_getsetlist[] = {
PyObject *it, *result, *meth_output;
assert(o != NULL);
- meth_output = _PyObject_CallMethodId(o, meth_id, NULL);
+ meth_output = _PyObject_CallMethodIdNoArgs(o, meth_id);
if (meth_output == NULL || PyList_CheckExact(meth_output)) {
return meth_output;
}
mappingproxy_keys(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(keys);
- return _PyObject_CallMethodId(pp->mapping, &PyId_keys, NULL);
+ return _PyObject_CallMethodIdNoArgs(pp->mapping, &PyId_keys);
}
static PyObject *
mappingproxy_values(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(values);
- return _PyObject_CallMethodId(pp->mapping, &PyId_values, NULL);
+ return _PyObject_CallMethodIdNoArgs(pp->mapping, &PyId_values);
}
static PyObject *
mappingproxy_items(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(items);
- return _PyObject_CallMethodId(pp->mapping, &PyId_items, NULL);
+ return _PyObject_CallMethodIdNoArgs(pp->mapping, &PyId_items);
}
static PyObject *
mappingproxy_copy(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(copy);
- return _PyObject_CallMethodId(pp->mapping, &PyId_copy, NULL);
+ return _PyObject_CallMethodIdNoArgs(pp->mapping, &PyId_copy);
}
/* WARNING: mappingproxy methods must not give access
}
if (n <= 0) {
- result = _PyObject_CallMethodIdObjArgs(f, &PyId_readline, NULL);
+ result = _PyObject_CallMethodIdNoArgs(f, &PyId_readline);
}
else {
result = _PyObject_CallMethodId(f, &PyId_readline, "i", n);
if (args == NULL)
goto Done;
- items = _PyObject_CallMethodIdObjArgs((PyObject *)od, &PyId_items, NULL);
+ items = _PyObject_CallMethodIdNoArgs((PyObject *)od, &PyId_items);
if (items == NULL)
goto Done;
Py_SIZE(pieces) = count;
}
else {
- PyObject *items = _PyObject_CallMethodIdObjArgs((PyObject *)self,
- &PyId_items, NULL);
+ PyObject *items = _PyObject_CallMethodIdNoArgs((PyObject *)self,
+ &PyId_items);
if (items == NULL)
goto Done;
pieces = PySequence_List(items);
PyObject *items;
_Py_IDENTIFIER(items);
- items = _PyObject_CallMethodIdObjArgs(obj, &PyId_items, NULL);
+ items = _PyObject_CallMethodIdNoArgs(obj, &PyId_items);
if (items == NULL) {
Py_CLEAR(*listitems);
return -1;
method(PyObject *proxy, PyObject *Py_UNUSED(ignored)) { \
_Py_IDENTIFIER(special); \
UNWRAP(proxy); \
- return _PyObject_CallMethodId(proxy, &PyId_##special, NULL); \
+ return _PyObject_CallMethodIdNoArgs(proxy, &PyId_##special); \
}
if (do_flush == -1)
return NULL;
else if (do_flush) {
- tmp = _PyObject_CallMethodId(file, &PyId_flush, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(file, &PyId_flush);
if (tmp == NULL)
return NULL;
else
}
/* First of all, flush stderr */
- tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(ferr, &PyId_flush);
if (tmp == NULL)
PyErr_Clear();
else
/* 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, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(fin, &PyId_fileno);
if (tmp == NULL) {
PyErr_Clear();
tty = 0;
tty = fd == fileno(stdin) && isatty(fd);
}
if (tty) {
- tmp = _PyObject_CallMethodId(fout, &PyId_fileno, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_fileno);
if (tmp == NULL) {
PyErr_Clear();
tty = 0;
stdin_errors_str = PyUnicode_AsUTF8(stdin_errors);
if (!stdin_encoding_str || !stdin_errors_str)
goto _readline_errors;
- tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_flush);
if (tmp == NULL)
PyErr_Clear();
else
if (PyFile_WriteObject(prompt, fout, Py_PRINT_RAW) != 0)
return NULL;
}
- tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_flush);
if (tmp == NULL)
PyErr_Clear();
else
}
/* Explicitly call file.flush() */
- PyObject *res = _PyObject_CallMethodId(file, &PyId_flush, NULL);
+ PyObject *res = _PyObject_CallMethodIdNoArgs(file, &PyId_flush);
if (!res) {
return -1;
}
}
else {
_Py_IDENTIFIER(clear);
- if (_PyObject_CallMethodId(modules, &PyId_clear, "") == NULL) {
+ if (_PyObject_CallMethodIdNoArgs(modules, &PyId_clear) == NULL) {
PyErr_WriteUnraisable(NULL);
}
}
int status = 0;
if (fout != NULL && fout != Py_None && !file_is_closed(fout)) {
- tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_flush);
if (tmp == NULL) {
PyErr_WriteUnraisable(fout);
status = -1;
}
if (ferr != NULL && ferr != Py_None && !file_is_closed(ferr)) {
- tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
+ tmp = _PyObject_CallMethodIdNoArgs(ferr, &PyId_flush);
if (tmp == NULL) {
PyErr_Clear();
status = -1;
text = PyUnicode_FromString(name);
if (text == NULL || _PyObject_SetAttrId(raw, &PyId_name, text) < 0)
goto error;
- res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
+ res = _PyObject_CallMethodIdNoArgs(raw, &PyId_isatty);
if (res == NULL)
goto error;
isatty = PyObject_IsTrue(res);
Py_XDECREF(tb);
/* sys.stderr may be buffered: call sys.stderr.flush() */
- res = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
+ res = _PyObject_CallMethodIdNoArgs(ferr, &PyId_flush);
if (res == NULL) {
_PyErr_Clear(tstate);
}
/* else: threading not imported */
return;
}
- result = _PyObject_CallMethodId(threading, &PyId__shutdown, NULL);
+ result = _PyObject_CallMethodIdNoArgs(threading, &PyId__shutdown);
if (result == NULL) {
PyErr_WriteUnraisable(threading);
}
Py_XDECREF(seen);
/* Call file.flush() */
- PyObject *res = _PyObject_CallMethodId(file, &PyId_flush, NULL);
+ PyObject *res = _PyObject_CallMethodIdNoArgs(file, &PyId_flush);
if (!res) {
/* Silently ignore file.flush() error */
PyErr_Clear();
f = _PySys_GetObjectId(&PyId_stderr);
if (f != NULL) {
- r = _PyObject_CallMethodId(f, &PyId_flush, NULL);
+ r = _PyObject_CallMethodIdNoArgs(f, &PyId_flush);
if (r)
Py_DECREF(r);
else
}
f = _PySys_GetObjectId(&PyId_stdout);
if (f != NULL) {
- r = _PyObject_CallMethodId(f, &PyId_flush, NULL);
+ r = _PyObject_CallMethodIdNoArgs(f, &PyId_flush);
if (r)
Py_DECREF(r);
else
if (fob == NULL) {
PyErr_Clear();
- res = _PyObject_CallMethodId(binary, &PyId_close, NULL);
+ res = _PyObject_CallMethodIdNoArgs(binary, &PyId_close);
Py_DECREF(binary);
if (res)
Py_DECREF(res);
break;
}
}
- res = _PyObject_CallMethodId(fob, &PyId_close, NULL);
+ res = _PyObject_CallMethodIdNoArgs(fob, &PyId_close);
if (res)
Py_DECREF(res);
else