Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commented Aug 28, 2023

Use PyTuple_Size() instead of PyTuple_GET_SIZE().

Use PyTuple_Size() instead of PyTuple_GET_SIZE().
@vstinner
Copy link
MemberAuthor

Issue found while converting syslog to the limited C API.

Comment on lines +1718 to +1721
nargs='PyTuple_Size(args)'
else:
nargs='PyTuple_GET_SIZE(args)'
add(f"switch ({nargs}){{\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style suggestion -- because of the f-strings needing the duplication of {, perhaps just being explicit in both cases would be worth it?

Suggested change
nargs='PyTuple_Size(args)'
else:
nargs='PyTuple_GET_SIZE(args)'
add(f"switch ({nargs}){{\n")
add("switch (PyTuple_Size(args)){\n")
else:
add("switch (PyTuple_GET_SIZE(args)){\n")

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, other than @AA-Turner's style nit, which I agree with :)

@vstinnervstinner merged commit e675e51 into python:mainAug 29, 2023
@vstinnervstinner deleted the ac_limited_option_group branch August 29, 2023 11:33
@vstinner
Copy link
MemberAuthor

Merged, thanks for reviews. I prefer to avoid repetition even if the f-string is just a little bit surprising.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@vstinner@AA-Turner@erlend-aasland@AlexWaygood@bedevere-bot