Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust inspect behaviour to support python >= 3.5 #13

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions bottle_redis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# -*- coding: utf-8 -*-
#
try:
from inspect import signature as ins_signature
signature = lambda obj: ins_signature(obj).parameters
except ImportError:
from inspect import getargspec
signature = lambda obj: getargspec(obj)[0]

import redis
import inspect
from bottle import __version__, PluginError
Expand Down Expand Up @@ -34,10 +42,7 @@ def apply(self, callback, route):
_callback = route.callback

conf = config.get('redis') or {}
try:
args = inspect.getargspec(_callback)[0]
except ValueError:
args = inspect.getfullargspec(_callback)[0] # FIXME deprecated since Python 3.5
args = signature(_callback)
keyword = conf.get('keyword', self.keyword)
if keyword not in args:
return callback
Expand Down