| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@rhettinger, do you like this fix? Or do you like a documentation change more? |
Sorry, something went wrong.
|
I think this can be both considered a new feature and a bugfix. I would consider it a new feature though so to avoid surprises. In particular, I would write a What's New entry as well. |
Sorry, something went wrong.
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
|
I've written the news entry and moved the code around a bit. @picnixz does it look good? |
Sorry, something went wrong.
|
New features are indeed not backported. I am a bit busy this week so I do not know when I can look at it again (and hearing from Serhiy would be good) |
Sorry, something went wrong.
… instance-bindable (pythonGH-144615) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
… instance-bindable (pythonGH-144615) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
| Back | FazBrowse Home | New Git URL |
Unbound methods (i.e. functions) become bound methods when regularly accessed as instance attributes. From the class level, the contract of Python is that the unbound method can be called like a function (the first argument to the call will be used as the conventional self) and the call will execute directly (no bound method in between). Following the contract, a natural expectation is that when generic methods are called as class attributes, the second argument will be used for dispatching, not the first (the conventional self).
To support descriptors like classmethod (that bind to something else than the instance), arguments are shifted by one even if __get__ method returns a method that is bound to a different object than the original self (_singledispatchmethod_get._obj). If one wants to receive that self in an arbitrary bound method as a regular argument, the workaround is easy: return a partial(bound method) to hack the check.
This is a low risk bugfix. The patch is meant to fix the following program: