inspect.isfunction() processes both inspect.isfunction(func) and
inspect.isfunction(partial(func, arg)) correctly but some other functions in the
inspect module (iscoroutinefunction, isgeneratorfunction and isasyncgenfunction)
lack this functionality. This commits adds a new check in the mentioned functions
in the inspect module so they can work correctly with arbitrarily nested partial
functions.
* bpo-32991: Add test capturing expectation.
DocTestFinder.find should return an empty list for doctests in a namespace package.
* bpo-32991: Restore expectation that inspect.getfile on a namespace package raises TypeError.
2018-03-05 18:29:08 -05:00
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి)
Some objects (like test mocks) auto-generate new objects on
attribute access, which can lead to an infinite loop in
inspect.unwrap().
Ensuring references are retained to otherwise temporary objects
and capping the size of the memo dict turns this case into a
conventional exception instead.
At the time when an abstract base class' __init_subclass__ runs,
ABCMeta.__new__ has not yet finished running, so in the presence of
__init_subclass__, inspect.isabstract() can no longer depend only on
TPFLAGS_IS_ABSTRACT.
This is still useful for single source Python 2/3 code
migrating away from inspect.getargspec(), but that wasn't
clear with the documented deprecation in place.
inspect.signature now reports the implicit ``.0`` parameters generated by
the compiler for comprehension and generator expression scopes as if they
were positional-only parameters called ``implicit0``.
Patch by Jelle Zijlstra.
The fix for Issue #21217 introduced a regression that caused
`inspect.getsource` to return incorrect results on nested
functions. The root cause of the regression was due to
switching the implementation to analyze the underlying
bytecode instead of the source code.
This commit switches things back to analyzing the source code
in a more complete way. The original bug and the regression
are both fixed by the new source code analysis.
The fix for Issue #21217 introduced a regression that caused
`inspect.getsource` to return incorrect results on nested
functions. The root cause of the regression was due to
switching the implementation to analyze the underlying
bytecode instead of the source code.
This commit switches things back to analyzing the source code
in a more complete way. The original bug and the regression
are both fixed by the new source code analysis.