24
24
import platform
25
25
import types
26
26
import struct
27
- import inspect
28
- from collections import namedtuple
29
27
30
28
PY2 = sys .version_info [0 ] == 2
31
29
PY3 = sys .version_info [0 ] >= 3
@@ -64,32 +62,6 @@ def str_to_bytes(s, encoding=None):
64
62
def bytes_to_str (b , encoding = None ):
65
63
return b .decode (encoding or 'utf-8' )
66
64
67
- # The signature version below is directly copied from Django,
68
- # https://github.com/django/django/pull/4846
69
- def signature (f ):
70
- sig = inspect .signature (f )
71
- args = [
72
- p .name for p in sig .parameters .values ()
73
- if p .kind == inspect .Parameter .POSITIONAL_OR_KEYWORD
74
- ]
75
- varargs = [
76
- p .name for p in sig .parameters .values ()
77
- if p .kind == inspect .Parameter .VAR_POSITIONAL
78
- ]
79
- varargs = varargs [0 ] if varargs else None
80
- keywords = [
81
- p .name for p in sig .parameters .values ()
82
- if p .kind == inspect .Parameter .VAR_KEYWORD
83
- ]
84
- keywords = keywords [0 ] if keywords else None
85
- defaults = [
86
- p .default for p in sig .parameters .values ()
87
- if p .kind == inspect .Parameter .POSITIONAL_OR_KEYWORD
88
- and p .default is not p .empty
89
- ] or None
90
- argspec = namedtuple ('Signature' , ['args' , 'defaults' ,
91
- 'varargs' , 'keywords' ])
92
- return argspec (args , defaults , varargs , keywords )
93
65
else :
94
66
# Python 2
95
67
_name_re = re .compile (r"[a-zA-Z_][a-zA-Z0-9_]*$" )
@@ -103,9 +75,6 @@ def str_to_bytes(s, encoding='ascii'):
103
75
def bytes_to_str (b , encoding = 'ascii' ):
104
76
return b
105
77
106
- def signature (f ):
107
- return inspect .getargspec (f )
108
-
109
78
if PY2 :
110
79
def iteritems (obj , ** kw ):
111
80
return obj .iteritems (** kw )
0 commit comments