Commit Graph

266 Commits

Author SHA1 Message Date
Yury Selivanov eb6364557f Issue #28003: Implement PEP 525 -- Asynchronous Generators. 2016-09-08 22:01:51 -07:00
Martin Panter 1aa642f6bd Issue #27993: Merge plural fixes from 3.5 2016-09-07 23:36:43 +00:00
Martin Panter 0f0eac431f Issue #27993: Fix problems with plural objects in docs and comments 2016-09-07 11:04:41 +00:00
Nick Coghlan b4b966ece2 Issue #19611: handle implicit parameters in inspect.signature
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.
2016-06-04 14:40:03 -07:00
Yury Selivanov 06495ffe93 Merge 3.5 (issue #26347) 2016-03-02 11:08:05 -05:00
Yury Selivanov f9e1f2bda9 inspect: Fix BoundArguments.apply_defaults to handle empty arguments
Patch by Frederick Wagner (issue #26347)
2016-03-02 11:07:47 -05:00
Yury Selivanov 37dc2b2883 Issue #25486: Resurrect inspect.getargspec in 3.6. Backout a565aad5d6e1.
The decision is that we shouldn't remove popular APIs (however long they
are depreacted) from Python 3, while 2.7 is still around and supported.
2016-01-11 15:15:01 -05:00
Serhiy Storchaka 6230235e83 Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
Original patch by John Mark Vandenberg.
2015-10-29 08:17:10 +02:00
Serhiy Storchaka ac4bdcc80e Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
Original patch by John Mark Vandenberg.
2015-10-29 08:15:50 +02:00
Berker Peksag fa3922cfd0 Issue #13248: Delete remaining references of inspect.getargspec().
Noticed by Yaroslav Halchenko.
2015-07-31 04:11:29 +03:00
Meador Inge f98c35a816 Issue #24485: Function source inspection fails on closures.
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.
2015-07-23 22:52:49 -05:00
Meador Inge 5b718d7f4f Issue #24485: Function source inspection fails on closures.
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.
2015-07-23 22:49:37 -05:00
Yury Selivanov 6dfbc5d98e Issue #13248: Remove inspect.getmoduleinfo() from 3.6 (deprecated in 3.3) 2015-07-23 17:49:00 +03:00
Yury Selivanov f1b5ccb993 Issue #13248: Remove inspect.getargspec from 3.6 (deprecated from 3.0) 2015-07-23 17:36:02 +03:00
Yury Selivanov 4f4913b38b Issue #24485: Revert backwards compatibility breaking changes of #21217. 2015-07-23 17:10:00 +03:00
Yury Selivanov e4e811d65b Issue #24669: Fix inspect.getsource() for 'async def' functions.
Patch by Kai Groner.
2015-07-21 19:01:52 +03:00
Serhiy Storchaka 2489bd5d4e Issue #24206: Fixed __eq__ and __ne__ methods of inspect classes. 2015-07-18 23:20:50 +03:00
Serhiy Storchaka 3018cc49e8 Issue #24206: Fixed __eq__ and __ne__ methods of inspect classes. 2015-07-18 23:19:05 +03:00
Yury Selivanov fdbeb2b4b6 Issue #24400: Resurrect inspect.isawaitable()
collections.abc.Awaitable and collections.abc.Coroutine no longer
use __instancecheck__ hook to detect generator-based coroutines.

inspect.isawaitable() can be used to detect generator-based coroutines
and to distinguish them from regular generator objects.
2015-07-03 13:11:35 -04:00
Yury Selivanov a74b5e59af Issue #24400: Remove inspect.isawaitable().
isawaitable() was added before collections.abc.Awaitable; now,
with Awaitable, it is no longer needed (we don't have ishashable()
or isiterable() methods in the inspect module either).
2015-06-30 18:19:01 -04:00
Yury Selivanov 5376ba9630 Issue #24400: Introduce a distinct type for 'async def' coroutines.
Summary of changes:

1. Coroutines now have a distinct, separate from generators
   type at the C level: PyGen_Type, and a new typedef PyCoroObject.
   PyCoroObject shares the initial segment of struct layout with
   PyGenObject, making it possible to reuse existing generators
   machinery.  The new type is exposed as 'types.CoroutineType'.

   As a consequence of having a new type, CO_GENERATOR flag is
   no longer applied to coroutines.

2. Having a separate type for coroutines made it possible to add
   an __await__ method to the type.  Although it is not used by the
   interpreter (see details on that below), it makes coroutines
   naturally (without using __instancecheck__) conform to
   collections.abc.Coroutine and collections.abc.Awaitable ABCs.

   [The __instancecheck__ is still used for generator-based
   coroutines, as we don't want to add __await__ for generators.]

3. Add new opcode: GET_YIELD_FROM_ITER.  The opcode is needed to
   allow passing native coroutines to the YIELD_FROM opcode.

   Before this change, 'yield from o' expression was compiled to:

      (o)
      GET_ITER
      LOAD_CONST
      YIELD_FROM

   Now, we use GET_YIELD_FROM_ITER instead of GET_ITER.

   The reason for adding a new opcode is that GET_ITER is used
   in some contexts (such as 'for .. in' loops) where passing
   a coroutine object is invalid.

4. Add two new introspection functions to the inspec module:
   getcoroutinestate(c) and getcoroutinelocals(c).

5. inspect.iscoroutine(o) is updated to test if 'o' is a native
   coroutine object.  Before this commit it used abc.Coroutine,
   and it was requested to update inspect.isgenerator(o) to use
   abc.Generator; it was decided, however, that inspect functions
   should really be tailored for checking for native types.

6. sys.set_coroutine_wrapper(w) API is updated to work with only
   native coroutines.  Since types.coroutine decorator supports
   any type of callables now, it would be confusing that it does
   not work for all types of coroutines.

7. Exceptions logic in generators C implementation was updated
   to raise clearer messages for coroutines:

   Before: TypeError("generator raised StopIteration")
   After: TypeError("coroutine raised StopIteration")
2015-06-22 12:19:30 -04:00
Yury Selivanov bf304fcb32 Issue #23934: Fix inspect.signature to fail correctly for builtin types.
Initial patch by James Powell.
2015-05-30 17:08:36 -04:00
Yury Selivanov 507cd3cf91 Issue 24298: Fix signature() to properly unwrap wrappers around bound methods 2015-05-27 21:59:03 -04:00
Yury Selivanov 46c759d76d Issue 24298: Fix signature() to properly unwrap wrappers around bound methods 2015-05-27 21:56:53 -04:00
Yury Selivanov c8386f78fd Issue 20438: Adjust stacklevel of inspect.getargspec() warning. 2015-05-22 16:09:44 -04:00
Yury Selivanov 3cfec2e2fc Issue 20438: Deprecate inspect.getargspec() and friends. 2015-05-22 11:38:38 -04:00
Berker Peksag b560158622 Set stacklevel to 2 to get more accurate warning messages from deprecated functions. 2015-05-21 23:40:54 +03:00
Yury Selivanov 095fb84fc2 Issue 23898: Fix inspect.classify_class_attrs() to work with __eq__
Patch by Mike Bayer.
2015-05-21 15:45:08 -04:00
Yury Selivanov bf341fb5f6 Issue 23898: Fix inspect.classify_class_attrs() to work with __eq__ 2015-05-21 15:41:57 -04:00
Yury Selivanov ff54223606 Issue 24017: Use abc.Coroutine in inspect.iscoroutine() function 2015-05-21 12:03:21 -04:00
Yury Selivanov 57c74fca02 Issue 24248: Deprecate inspect.Signature.from_function and .from_builtin 2015-05-20 23:07:02 -04:00
Yury Selivanov cf45f022b7 inspect.Signature: Factor out Signature.from_function to a private helper 2015-05-20 14:38:50 -04:00
Yury Selivanov bcd4fc161a Issue 20691: Add follow_wrapped arg to inspect.signature/from_callable. 2015-05-20 14:30:08 -04:00
Yury Selivanov 8687275358 Issue 24205: Improve inspect.Signature.bind() error messages. 2015-05-19 00:27:49 -04:00
Yury Selivanov b907a513c8 Issue 24190: Add inspect.BoundArguments.apply_defaults() method. 2015-05-16 13:45:09 -04:00
Yury Selivanov f229bc5c53 inspect: Remove "0x..." IDs from Signature objects' __repr__
Issue 24200.
2015-05-15 12:53:56 -04:00
Yury Selivanov 3f6538fed0 Issue 22547: Implement informative __repr__ for inspect.BoundArguments 2015-05-14 18:47:17 -04:00
Yury Selivanov 692b340092 inspect: Micro-optimize __eq__ for Signature, Parameter and BoundArguments
Provide __ne__ method for consistency.
2015-05-14 18:20:01 -04:00
Yury Selivanov 6abe03288b inspect: Add __slots__ to BoundArguments. 2015-05-13 17:18:41 -04:00
Yury Selivanov 7544508f02 PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
Antoine Pitrou a8723a02ea Issue #21217: inspect.getsourcelines() now tries to compute the start and
end lines from the code object, fixing an issue when a lambda function is
used as decorator argument.  Patch by Thomas Ballinger.
2015-04-15 00:41:29 +02:00
Serhiy Storchaka 5cf2b7253d Issue #15582: inspect.getdoc() now follows inheritance chains. 2015-04-03 22:38:53 +03:00
Serhiy Storchaka 08448a1f4d Issue #23326: Removed __ne__ implementations. Since fixing default __ne__
implementation in issue #21408 they are redundant.
2015-01-31 12:05:05 +02:00
Yury Selivanov ef1e750225 inspect: Fix getsource() to load updated source of reloaded module
Issue #1218234. Initial patch by Berker Peksag.
2014-12-08 16:05:34 -05:00
Berker Peksag 1ed2e69a4a Issue #22186: Fix typos in Lib/.
Patch by Févry Thibault.
2014-10-19 18:07:05 +03:00
Berker Peksag f23530f569 Issue #22186: Fix typos in Lib/.
Patch by Févry Thibault.
2014-10-19 18:04:38 +03:00
Yury Selivanov 081bbf6b28 inspect: Fix getsource() to support decorated functions.
Issue #1764286. Patch by Claudiu Popa.
2014-09-26 17:34:54 -04:00
Yury Selivanov 08d4a4f488 inspect.Signature: Fix discrepancy between __eq__ and __hash__.
Issue #20334. Thanks to Antony Lee for bug report & initial patch.
2014-09-12 15:48:02 -04:00
Antoine Pitrou cdcafb78b2 Issue #16808: inspect.stack() now returns a named tuple instead of a tuple.
Patch by Daniel Shahaf.
2014-08-24 10:50:28 -04:00
Serhiy Storchaka 521e5860a5 Issue #22032: __qualname__ instead of __name__ is now always used to format
fully qualified class names of Python implemented classes.
2014-07-22 15:00:37 +03:00