1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
From 232f671fd0a28d435550afc4e2a9fde63c9e0db2 Mon Sep 17 00:00:00 2001
From: Riley Banks <waultah@gmail.com>
Date: Sun, 11 Oct 2015 10:21:43 +0100
Subject: [PATCH] Implement getargspec using inspect.Signature
---
bottle.py | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/bottle.py b/bottle.py
index 9806efd..18ed730 100644
--- a/bottle.py
+++ b/bottle.py
@@ -41,9 +41,27 @@ import base64, cgi, email.utils, functools, hmac, itertools, mimetypes,\
from datetime import date as datedate, datetime, timedelta
from tempfile import TemporaryFile
from traceback import format_exc, print_exc
-from inspect import getargspec
from unicodedata import normalize
+# inspect.getargspec was removed in Python 3.6, use
+# Signature-based version where we can (Python 3.3+)
+try:
+ from inspect import signature
+ def getargspec(func):
+ params = signature(func).parameters
+ args, varargs, keywords, defaults = [], None, None, []
+ for name, param in params.items():
+ if param.kind == param.VAR_POSITIONAL:
+ varargs = name
+ elif param.kind == param.VAR_KEYWORD:
+ keywords = name
+ else:
+ args.append(name)
+ if param.default is not param.empty:
+ defaults.append(param.default)
+ return (args, varargs, keywords, tuple(defaults) or defaults)
+except ImportError:
+ from inspect import getargspec
try: from simplejson import dumps as json_dumps, loads as json_lds
except ImportError: # pragma: no cover
--
2.35.1
|