diff options
| author | Tim Graham <timograham@gmail.com> | 2015-06-10 17:24:04 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-15 13:43:22 -0400 |
| commit | 3872a33132a4bb6aa22b237927597bbfdf6f21d7 (patch) | |
| tree | fc3f7de9a6eb0169751b2493b11153697a8bb0dd /django/dispatch | |
| parent | 4b600ed24488b2d1fc0fd59fc883a84ee745fcf8 (diff) | |
| download | django-3872a33132a4bb6aa22b237927597bbfdf6f21d7.tar.gz | |
Fixed #24979 -- Removed usage of inspect.getargspec().
Diffstat (limited to 'django/dispatch')
| -rw-r--r-- | django/dispatch/dispatcher.py | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/django/dispatch/dispatcher.py b/django/dispatch/dispatcher.py index a8181b7ec6..b2d774bda6 100644 --- a/django/dispatch/dispatcher.py +++ b/django/dispatch/dispatcher.py @@ -4,6 +4,7 @@ import warnings import weakref from django.utils.deprecation import RemovedInDjango21Warning +from django.utils.inspect import func_accepts_kwargs from django.utils.six.moves import range if sys.version_info < (3, 4): @@ -89,24 +90,11 @@ class Signal(object): # If DEBUG is on, check that we got a good receiver if settings.configured and settings.DEBUG: - import inspect assert callable(receiver), "Signal receivers must be callable." # Check for **kwargs - # Not all callables are inspectable with getargspec, so we'll - # try a couple different ways but in the end fall back on assuming - # it is -- we don't want to prevent registration of valid but weird - # callables. - try: - argspec = inspect.getargspec(receiver) - except TypeError: - try: - argspec = inspect.getargspec(receiver.__call__) - except (TypeError, AttributeError): - argspec = None - if argspec: - assert argspec[2] is not None, \ - "Signal receivers must accept keyword arguments (**kwargs)." + if not func_accepts_kwargs(receiver): + raise ValueError("Signal receivers must accept keyword arguments (**kwargs).") if dispatch_uid: lookup_key = (dispatch_uid, _make_id(sender)) |
