1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #24979 -- Removed usage of inspect.getargspec().

This commit is contained in:
Tim Graham
2015-06-10 17:24:04 -04:00
parent 4b600ed244
commit 3872a33132
13 changed files with 118 additions and 40 deletions

View File

@@ -51,10 +51,10 @@ u'<html></html>'
from __future__ import unicode_literals
import inspect
import logging
import re
import warnings
from inspect import getargspec, getcallargs
from django.template.context import ( # NOQA: imported for backwards compatibility
BaseContext, Context, ContextPopException, RequestContext,
@@ -66,6 +66,7 @@ from django.utils.encoding import (
)
from django.utils.formats import localize
from django.utils.html import conditional_escape, escape
from django.utils.inspect import getargspec
from django.utils.safestring import (
EscapeData, SafeData, mark_for_escaping, mark_safe,
)
@@ -723,7 +724,8 @@ class FilterExpression(object):
plen = len(provided) + 1
# Check to see if a decorator is providing the real function.
func = getattr(func, '_decorated_function', func)
args, varargs, varkw, defaults = getargspec(func)
args, _, _, defaults = getargspec(func)
alen = len(args)
dlen = len(defaults or [])
# Not enough OR Too many
@@ -884,7 +886,7 @@ class Variable(object):
current = current()
except TypeError:
try:
getcallargs(current)
inspect.getcallargs(current)
except TypeError: # arguments *were* required
current = context.template.engine.string_if_invalid # invalid method call
else:

View File

@@ -1,10 +1,10 @@
import functools
import warnings
from importlib import import_module
from inspect import getargspec
from django.utils import six
from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.inspect import getargspec
from django.utils.itercompat import is_iterable
from .base import Node, Template, token_kwargs

View File

@@ -1,8 +1,8 @@
import warnings
from inspect import getargspec
from django.template import Origin, Template, TemplateDoesNotExist
from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.inspect import func_supports_parameter
class Loader(object):
@@ -28,7 +28,7 @@ class Loader(object):
args = [template_name]
# RemovedInDjango21Warning: Add template_dirs for compatibility with
# old loaders
if 'template_dirs' in getargspec(self.get_template_sources)[0]:
if func_supports_parameter(self.get_template_sources, 'template_dirs'):
args.append(template_dirs)
for origin in self.get_template_sources(*args):

View File

@@ -5,11 +5,11 @@ to load templates from them in order, caching the result.
import hashlib
import warnings
from inspect import getargspec
from django.template import Origin, Template, TemplateDoesNotExist
from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.encoding import force_bytes
from django.utils.inspect import func_supports_parameter
from .base import Loader as BaseLoader
@@ -51,7 +51,7 @@ class Loader(BaseLoader):
args = [template_name]
# RemovedInDjango21Warning: Add template_dirs for compatibility
# with old loaders
if 'template_dirs' in getargspec(loader.get_template_sources)[0]:
if func_supports_parameter(loader.get_template_sources, 'template_dirs'):
args.append(template_dirs)
for origin in loader.get_template_sources(*args):
yield origin