Skip to content

Conversation

StanFromIreland
Copy link
Member

@StanFromIreland StanFromIreland commented Oct 20, 2025

@merwok
Copy link
Member

merwok commented Oct 20, 2025

Could you create a new issue for this, and tag people interested in AC?

@StanFromIreland
Copy link
Member Author

I can create a new issue, but all CODEOWNERs have already been notified. Do you have anyone else in mind?

@StanFromIreland StanFromIreland changed the title gh-76007: Add support for __getattr__ method to Argument Clinic gh-140382: Add support for __getattr__ method to Argument Clinic Oct 20, 2025
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Wouldn't it make more sense to just support arbitrary dunder methods? __getattr__ isn't very common in C code, among other things.

@AA-Turner
Copy link
Member

AA-Turner commented Oct 20, 2025

I'm also not convinced this is worth it. __getattr__() really ought to be implemented at the Python level, modules implemented entirely in C (like zlib) are very much a special case, and aren't used for new stdlib modules.

A

@ZeroIntensity
Copy link
Member

On the other hand, I would be very supportive of allowing arbitrary dunders in AC, though I suspect that would be a lot of extra work (because we would need to map dunders to PyTypeObject fields).

@merwok
Copy link
Member

merwok commented Oct 20, 2025

I can create a new issue, but all CODEOWNERs have already been notified. Do you have anyone else in mind?

No, it’s just the general principle that «should we do?» discussions happen in issues (and when needed on the forums), then the PR can host «how to do?» discussions.

Copy link
Contributor

@skirpichev skirpichev left a comment

Choose a reason for hiding this comment

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

Wouldn't it make more sense to just support arbitrary dunder methods?

I think it's ok to add support of specific dunders on-demand. It's not too helpful in general, because sometimes we can do too much with slots, even override the docstring.

But please think about more generic case. For example, for most dunders we have very specific function signatures. It will be redundant and error-prone to specify this stuff by hand.

/*[clinic input]
zlib.__getattr__
name: object
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: object
name: str

I think we want here a string, isn't? And remove PyUnicode_Check() in zlib___getattr__()

Also, we want this always. Maybe per-default the AC should set an appropriate signature?

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.

5 participants