Skip to content

Commit 8d372e2

Browse files
geoffbacondbieber
authored andcommitted
Exposes builtin functions from the standard library (#193)
* fixes #187
1 parent 720c0aa commit 8d372e2

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

fire/inspectutils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__ import print_function
2020

2121
import inspect
22+
import types
2223
from fire import docstrings
2324

2425
import six
@@ -70,16 +71,19 @@ class with an __init__ method.
7071
"""
7172
skip_arg = False
7273
if inspect.isclass(fn):
73-
# If the function is a class, we try to use it's init method.
74+
# If the function is a class, we try to use its init method.
7475
skip_arg = True
7576
if six.PY2 and hasattr(fn, '__init__'):
7677
fn = fn.__init__
7778
elif inspect.ismethod(fn):
7879
# If the function is a bound method, we skip the `self` argument.
7980
skip_arg = fn.__self__ is not None
8081
elif inspect.isbuiltin(fn):
81-
# If the function is a bound builtin, we skip the `self` argument.
82-
skip_arg = fn.__self__ is not None
82+
# If the function is a bound builtin, we skip the `self` argument, unless
83+
# the function is from a standard library module in which case its __self__
84+
# attribute is that module.
85+
if not isinstance(fn.__self__, types.ModuleType):
86+
skip_arg = True
8387
elif not inspect.isfunction(fn):
8488
# The purpose of this else clause is to set skip_arg for callable objects.
8589
skip_arg = True

0 commit comments

Comments
 (0)