mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #24979 -- Removed usage of inspect.getargspec().
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user