Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-46255: Remove unnecessary check in _IOBase._check*() methods #30397

Closed
wants to merge 1 commit into from
Closed

bpo-46255: Remove unnecessary check in _IOBase._check*() methods #30397

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 4, 2022

These methods are METH_NOARGS, in all cases the second parameter will be NULL.

    {"_checkClosed",   _PyIOBase_check_closed, METH_NOARGS},
    {"_checkSeekable", _PyIOBase_check_seekable, METH_NOARGS},
    {"_checkReadable", _PyIOBase_check_readable, METH_NOARGS},
    {"_checkWritable", _PyIOBase_check_writable, METH_NOARGS},

https://bugs.python.org/issue46255

These methods are METH_NOARGS, in all cases the second parameter will be NULL.
@encukou
Copy link
Member

encukou commented Jan 19, 2022

in all cases the second parameter will be NULL.

Unfortunately, that's not true. They are called from other C code as well:

else if (_PyIOBase_check_closed((PyObject *)self, Py_True) == NULL) \

if (_PyIOBase_check_seekable(self->raw, Py_True) == NULL)

if (_PyIOBase_check_readable(raw, Py_True) == NULL)

if (_PyIOBase_check_writable(raw, Py_True) == NULL)

This would be a nice simplification if that wasn't the case!

@encukou encukou closed this Jan 19, 2022
@ghost ghost deleted the iobase branch April 4, 2022 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants