2121from flask import current_app , request , url_for
2222from werkzeug .utils import import_string
2323
24- from ._compat import PY2 , iteritems
24+ from flask_caching ._compat import PY2 , iteritems
2525
2626__version__ = "1.4.0"
2727
@@ -198,7 +198,7 @@ def init_app(self, app, config=None):
198198 and not config ["CACHE_NO_NULL_WARNING" ]
199199 ):
200200 warnings .warn (
201- "Flask-Cache : CACHE_TYPE is set to null, "
201+ "Flask-Caching : CACHE_TYPE is set to null, "
202202 "caching is effectively disabled."
203203 )
204204
@@ -219,7 +219,7 @@ def _set_cache(self, app, config):
219219 cache_obj = getattr (backends , import_me )
220220 except AttributeError :
221221 raise ImportError (
222- "%s is not a valid FlaskCache backend" % (import_me )
222+ "%s is not a valid Flask-Caching backend" % (import_me )
223223 )
224224 else :
225225 cache_obj = import_string (import_me )
@@ -411,8 +411,13 @@ def make_cache_key(*args, **kwargs):
411411 # Convert non-keyword arguments (which is the way
412412 # `make_cache_key` expects them) to keyword arguments
413413 # (the way `url_for` expects them)
414- argspec = inspect .getargspec (f )
415- for arg_name , arg in zip (argspec .args , args ):
414+ try :
415+ # Python >= 3.0
416+ argspec_args = inspect .getfullargspec (f ).args
417+ except AttributeError :
418+ argspec_args = inspect .getargspec (f ).args
419+
420+ for arg_name , arg in zip (argspec_args , args ):
416421 kwargs [arg_name ] = arg
417422
418423 return _make_cache_key (args , kwargs , use_request = False )
@@ -619,7 +624,7 @@ def _memoize_kwargs_to_args(self, f, *args, **kwargs):
619624
620625 new_args .append (arg )
621626
622- new_args .extend (args [len (arg_names ) :])
627+ new_args .extend (args [len (arg_names ):])
623628 return (
624629 tuple (new_args ),
625630 OrderedDict (
@@ -639,7 +644,11 @@ def _bypass_cache(self, unless, f, *args, **kwargs):
639644 bypass_cache = False
640645
641646 if callable (unless ):
642- argspec = inspect .getargspec (unless )
647+ try :
648+ # Python >= 3.0
649+ argspec = inspect .getfullargspec (unless )
650+ except AttributeError :
651+ argspec = inspect .getargspec (unless )
643652
644653 # If unless() takes args, pass them in.
645654 if len (argspec .args ) > 0 and argspec .varargs and argspec .keywords :
@@ -714,6 +723,7 @@ def big_foo(a, b):
714723 renewal of cached functions.
715724 :param hash_method: Default hashlib.md5. The hash method used to
716725 generate the keys for cached results.
726+
717727 .. versionadded:: 0.5
718728 params ``make_name``, ``unless``
719729 """
0 commit comments