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

Use METH_NOARGS when no arguments are required #5488

Merged
merged 2 commits into from May 19, 2021

Conversation

radarhere
Copy link
Member

This PR first replaces '1' with METH_VARARGS in various locations, improving clarity. Changing code like this -

Pillow/src/_imaging.c

Lines 3421 to 3425 in d393cfb

static struct PyMethodDef methods[] = {
/* Put commonly used methods first */
{"getpixel", (PyCFunction)_getpixel, 1},
{"putpixel", (PyCFunction)_putpixel, 1},

to match how it is specified elsewhere in Pillow -

Pillow/src/_imagingft.c

Lines 1228 to 1230 in d393cfb

static PyMethodDef font_methods[] = {
{"render", (PyCFunction)font_render, METH_VARARGS},
{"getsize", (PyCFunction)font_getsize, METH_VARARGS},

Then, this PR resolves #5487. The issue identifies 7 functions where we can use METH_NOARGS when no arguments are being used, rather than always using METH_VARARGS. This update is similar to #4441

@hugovk
Copy link
Member

hugovk commented May 19, 2021

Thanks!

@radarhere radarhere deleted the args branch May 19, 2021 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling conventions of some Python foreign functions mismatch with their C implementations
2 participants