2424import platform
2525import types
2626import struct
27- import inspect
28- from collections import namedtuple
2927
3028PY2 = sys .version_info [0 ] == 2
3129PY3 = sys .version_info [0 ] >= 3
@@ -64,32 +62,6 @@ def str_to_bytes(s, encoding=None):
6462 def bytes_to_str (b , encoding = None ):
6563 return b .decode (encoding or 'utf-8' )
6664
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 )
9365else :
9466 # Python 2
9567 _name_re = re .compile (r"[a-zA-Z_][a-zA-Z0-9_]*$" )
@@ -103,9 +75,6 @@ def str_to_bytes(s, encoding='ascii'):
10375 def bytes_to_str (b , encoding = 'ascii' ):
10476 return b
10577
106- def signature (f ):
107- return inspect .getargspec (f )
108-
10978if PY2 :
11079 def iteritems (obj , ** kw ):
11180 return obj .iteritems (** kw )
0 commit comments