summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpgjones <philip.graham.jones@googlemail.com>2023-01-22 14:09:48 +0000
committerPhil Jones <philip.graham.jones@googlemail.com>2023-01-24 20:12:59 +0000
commit0d4ca6e72c155e30aedd4315e8678ee9cada32b4 (patch)
tree5c273d5f24139a94b96658ac8e2eacc15374f391
parentd06b2416ea43c535b907b7d0a2b72fff3b2f3a0f (diff)
downloadblinker-0d4ca6e72c155e30aedd4315e8678ee9cada32b4.tar.gz
Allow int senders
This allows int values as senders much in the same way string values are allowed.
-rw-r--r--src/blinker/_utilities.py2
-rw-r--r--tests/test_signals.py15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/blinker/_utilities.py b/src/blinker/_utilities.py
index d64d8e8..68e8422 100644
--- a/src/blinker/_utilities.py
+++ b/src/blinker/_utilities.py
@@ -47,7 +47,7 @@ def hashable_identity(obj):
return (id(obj.__func__), id(obj.__self__))
elif hasattr(obj, "im_func"):
return (id(obj.im_func), id(obj.im_self))
- elif isinstance(obj, str):
+ elif isinstance(obj, (int, str)):
return obj
else:
return id(obj)
diff --git a/tests/test_signals.py b/tests/test_signals.py
index e79ff7f..4f1114d 100644
--- a/tests/test_signals.py
+++ b/tests/test_signals.py
@@ -532,3 +532,18 @@ def test_mute_signal():
def values_are_empty_sets_(dictionary):
for val in dictionary.values():
assert val == set()
+
+
+def test_int_sender():
+ sentinel = []
+
+ def received(sender):
+ sentinel.append(sender)
+
+ sig = blinker.Signal()
+
+ sig.connect(received, sender=123456789)
+ sig.send(123456789)
+ assert len(sentinel) == 1
+ sig.send(123456789 + 0) # Forces a new id with CPython
+ assert len(sentinel) == 2