-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Require calling a _BoundMethodProxy to get the underlying callable. #9084
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
Require calling a _BoundMethodProxy to get the underlying callable. #9084
Conversation
bef9d16
to
28fd2d7
Compare
rewritten to use weakref.WeakMethod directly edit: needs some more work. |
28fd2d7
to
fb6b895
Compare
rebased |
7e682ba
to
ad09280
Compare
# Note proxy not needed in python 3. | ||
# TODO rewrite this when support for python2.x gets dropped. | ||
proxy = _BoundMethodProxy(func) | ||
self._func_cid_map.setdefault(s, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pros / cons of using ismthod
vs try:....except:...
on attempting to create the WeakMethod
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited accordingly.
As mentioned elsewhere I believe quite strongly that the use of weakmethod semantics is pretty silly anyways...
ad09280
to
04ebedc
Compare
04ebedc
to
85e07fb
Compare
Circle builds the commit on the branch (rather than the commit from doing the merge) so those won't fix them selves. |
@@ -0,0 +1,6 @@ | |||
`CallbackRegistry` now stores callbacks using stdlib's `WeakMethods` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be WeakMethod
```````````````````````````````````````````````````````````````````` | ||
|
||
In particular, this implies that ``CallbackRegistry.callbacks[signal]`` is now | ||
a mapping of callback ids to `WeakMethods` (i.e., they need to be first called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also WeakMethod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed x2
Code that used to call `_proxy(...)` now needs to call `_proxy()(...)`. Instead of catching a ReferenceError, that could be either raised by a failure to dereference the proxy, or by the underlying callable, one can now check that `_proxy()` does not return None (to distinguish between the two cases). This is the same design as the stdlib's WeakMethod.
85e07fb
to
5257c4f
Compare
return self._hash | ||
|
||
|
||
def _exception_printer(exc): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we need this anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still there (line 65) and unchanged, the diff is just confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, great sorry for the noise.
Code that used to call
_proxy(...)
now needs to call_proxy()(...)
.Instead of catching a ReferenceError, that could be either raised by a
failure to dereference the proxy, or by the underlying callable, one can
now check that
_proxy()
does not return None (to distinguish betweenthe two cases).
This is the same design as the stdlib's WeakMethod.
See #9063 (comment).
PR Summary
PR Checklist