From 5fcbeee0212cc879ba441e5db43074fdbc2dfdd8 Mon Sep 17 00:00:00 2001 From: "crown.hg" Date: Fri, 17 May 2024 10:00:46 +0800 Subject: [PATCH] fix: AttributeError: module 'inspect' has no attribute 'getargspec'. --- bottle_sqlite.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) mode change 100755 => 100644 bottle_sqlite.py diff --git a/bottle_sqlite.py b/bottle_sqlite.py old mode 100755 new mode 100644 index 7fa0e7b..a6e0404 --- a/bottle_sqlite.py +++ b/bottle_sqlite.py @@ -111,8 +111,18 @@ def apply(self, callback, route): # Test if the original callback accepts a 'db' keyword. # Ignore it if it does not need a database handle. - argspec = inspect.getargspec(_callback) - if keyword not in argspec.args: + # argspec = inspect.getargspec(_callback) + # fix: AttributeError: module 'inspect' has no attribute 'getargspec'. + cbargs = [] + if hasattr(inspect, 'getargspec'): + argspec = inspect.getargspec(_callback) + cbargs = argspec.args + + if hasattr(inspect, 'getfullargspec'): + fullArgSpec = inspect.getfullargspec(_callback) + cbargs = fullArgSpec.args + + if keyword not in cbargs: return callback def wrapper(*args, **kwargs):