Show More
@@ -25,6 +25,7 b' Authors:' | |||
|
25 | 25 | |
|
26 | 26 | # Stdlib imports |
|
27 | 27 | import abc |
|
28 | import inspect | |
|
28 | 29 | import sys |
|
29 | 30 | import types |
|
30 | 31 | import warnings |
@@ -61,15 +62,21 b' def _valid_formatter(f):' | |||
|
61 | 62 | |
|
62 | 63 | - bound methods OK |
|
63 | 64 | - unbound methods NO |
|
64 |
- |
|
|
65 | - callable with zero args OK | |
|
65 | 66 | """ |
|
66 |
if isinstance(f, types. |
|
|
67 | # bound methods are okay, unbound are not | |
|
68 | return f.__self__ is not None | |
|
69 | elif isinstance(f, type(str.find)): | |
|
67 | if isinstance(f, type(str.find)): | |
|
70 | 68 | # unbound methods on compiled classes have type method_descriptor |
|
71 | 69 | return False |
|
70 | elif isinstance(f, types.BuiltinFunctionType): | |
|
71 | # bound methods on compiled classes have type builtin_function | |
|
72 | return True | |
|
72 | 73 | elif callable(f): |
|
74 | # anything that works with zero args should be okay | |
|
75 | try: | |
|
76 | inspect.getcallargs(f) | |
|
77 | except TypeError: | |
|
78 | return False | |
|
79 | else: | |
|
73 | 80 | return True |
|
74 | 81 | return False |
|
75 | 82 |
General Comments 0
You need to be logged in to leave comments.
Login now