1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Refs #24205 -- Removed Signal.disconnect()'s weak argument.

Per deprecation timeline.
This commit is contained in:
Tim Graham 2016-11-07 14:46:42 +00:00
parent e8dac72a55
commit 03087f80d1
5 changed files with 5 additions and 39 deletions

View File

@ -1,10 +1,8 @@
import warnings
from functools import partial
from django.db.models.utils import make_model_tuple
from django.dispatch import Signal
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
class_prepared = Signal(providing_args=["class"])
@ -32,9 +30,7 @@ class ModelSignal(Signal):
weak=weak, dispatch_uid=dispatch_uid,
)
def disconnect(self, receiver=None, sender=None, weak=None, dispatch_uid=None, apps=None):
if weak is not None:
warnings.warn("Passing `weak` to disconnect has no effect.", RemovedInDjango20Warning, stacklevel=2)
def disconnect(self, receiver=None, sender=None, dispatch_uid=None, apps=None):
return self._lazy_method(
super(ModelSignal, self).disconnect, apps, receiver, sender, dispatch_uid=dispatch_uid
)

View File

@ -1,10 +1,8 @@
import sys
import threading
import warnings
import weakref
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.inspect import func_accepts_kwargs
from django.utils.six.moves import range
@ -126,7 +124,7 @@ class Signal(object):
self.receivers.append((lookup_key, receiver))
self.sender_receivers_cache.clear()
def disconnect(self, receiver=None, sender=None, weak=None, dispatch_uid=None):
def disconnect(self, receiver=None, sender=None, dispatch_uid=None):
"""
Disconnect receiver from sender for signal.
@ -145,8 +143,6 @@ class Signal(object):
dispatch_uid
the unique identifier of the receiver to disconnect
"""
if weak is not None:
warnings.warn("Passing `weak` to disconnect has no effect.", RemovedInDjango20Warning, stacklevel=2)
if dispatch_uid:
lookup_key = (dispatch_uid, _make_id(sender))
else:

View File

@ -233,3 +233,6 @@ These features have reached the end of their deprecation cycle and are removed
in Django 2.0. See :ref:`deprecated-features-1.9` and
:ref:`deprecated-features-1.10` for details, including how to remove usage of
these features.
* The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` is
removed.

View File

@ -277,8 +277,3 @@ arguments are as described in :meth:`.Signal.connect`. The method returns
The ``receiver`` argument indicates the registered receiver to disconnect. It
may be ``None`` if ``dispatch_uid`` is used to identify the receiver.
.. deprecated:: 1.9
The ``weak`` argument is deprecated as it has no effect. It will be removed
in Django 2.0.

View File

@ -1,24 +0,0 @@
import warnings
from django.dispatch import Signal
from django.test import SimpleTestCase
a_signal = Signal(providing_args=['val'])
def receiver_1_arg(val, **kwargs):
return val
class DispatcherTests(SimpleTestCase):
def test_disconnect_weak_deprecated(self):
a_signal.connect(receiver_1_arg)
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter('always')
a_signal.disconnect(receiver_1_arg, weak=True)
self.assertEqual(len(warns), 1)
self.assertEqual(
str(warns[0].message),
'Passing `weak` to disconnect has no effect.',
)