Skip to content

Conversation

@asukaminato0721
Copy link
Contributor

fix #821

Bound-method attribute resolution now also consults the wrapped function type before giving up, so descriptors that attach helpers like clear_cache remain visible after binding; this is handled by expanding the Type::BoundMethod branch to recurse into func.as_type() alongside the existing types.MethodType lookup.

@meta-cla meta-cla bot added the cla signed label Nov 7, 2025
@asukaminato0721 asukaminato0721 marked this pull request as ready for review November 7, 2025 20:36
Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

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

This looks like a great start, thanks!

I think there's one issue here which is that we're abusing a data structure intended to track unions - the vec of AtrributeBase1 in AttributeBase, to do something pretty different.

I think we need to handle this case with a single AttributeBase1 instead of two of them to maintain code simplicity.

One option that might work would be to just make BoundMethodFunction attribute lookup fall back to self.stdlib.method_type().clone() at attribute lookup time for not-found attributes.

But actually I think there's another option, which is to take a peek at the bound_method type that's inside Type::BoundMethod(bound_method)... the self.stdlib.method_type().clone() is really specifically for built-in method descriptors, whereas the case we're handling here is a custom descriptor. So we probably could just use the actual type bound_method.func when it isn't Callable or types.FunctionType.

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.

Can't call function on object that is also a method

2 participants