Commit Graph

294 Commits

Author SHA1 Message Date
Miss Islington (bot) c8348fb6d2
bpo-33594: Add deprecation info in inspect.py module (GH-7036)
(cherry picked from commit ded87d804e)

Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
2018-10-19 17:05:49 -07:00
Miss Islington (bot) 476c294f26 bpo-34871: inspect: Don't pollute sys.modules (GH-9696) (#9701)
https://bugs.python.org/issue34871
(cherry picked from commit 6f85b826b5)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-10-04 15:26:33 -04:00
Miss Islington (bot) 3e6020c4dd
bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks (GH-8864)
(cherry picked from commit 91cb298f81)

Co-authored-by: Vladimir Matveev <v2matveev@outlook.com>
2018-08-24 10:44:47 -04:00
Miss Islington (bot) 8379b70be2 bpo-33582: Remove duplicate space in inspect.formatargspec() deprecation warning (GH-7655) (GH-7657)
(cherry picked from commit 41254ebd5e)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-06-12 00:25:31 -04:00
Miss Islington (bot) 60b8274fec
bpo-33582: Emit deprecation warning for `formatargspec` (GH-6994)
(cherry picked from commit 46c5cd0f6e)

Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
2018-06-11 13:44:16 -07:00
Miss Islington (bot) cb055bcc2b bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636) (GH-7204)
(cherry picked from commit a9cab433bb)

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2018-05-29 11:43:54 -04:00
Miss Islington (bot) 112f799666
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004)
(cherry picked from commit 8a387219bd)

Co-authored-by: Yury Selivanov <yury@magic.io>
2018-03-06 10:23:48 -08:00
Miss Islington (bot) 5a0c3987ab bpo-32991: Restore expectation that inspect.getfile raises TypeError on namespace package (GH-5980) (GH-5997)
* 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.
(cherry picked from commit b9650a04a8)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2018-03-06 10:16:11 -05:00
INADA Naoki 37420deb80
bpo-32678: inspect: Import ast lazily (GH-5344) 2018-01-27 10:10:06 +09:00
Serhiy Storchaka 3327a2ddf1
bpo-32265: Classify class and static methods of builtin types. (#4776)
Add types.ClassMethodDescriptorType for unbound class methods.
2017-12-15 14:13:41 +02:00
Serhiy Storchaka a4a3020abc
bpo-32157: Removed explicit quotes around %r and {!r}. (#4582) 2017-11-28 22:54:42 +02:00
Dong-hee Na 762b9571c9 bpo-32018: Fix inspect.signature repr to follow PEP 8 (#4408) 2017-11-15 13:30:59 -05:00
Thomas Kluyver e968bc7357 bpo-30639: Lazily compute repr for error (#2132) 2017-10-24 08:42:36 -04:00
Thomas Kluyver f9169ce6b4 bpo-25532: Protect against infinite loops in inspect.unwrap() (#1717)
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.
2017-05-23 13:27:52 +10:00
Jon Dufresne 3972628de3 bpo-30296 Remove unnecessary tuples, lists, sets, and dicts (#1489)
* Replaced list(<generator expression>) with list comprehension
* Replaced dict(<generator expression>) with dict comprehension
* Replaced set(<list literal>) with set literal
* Replaced builtin func(<list comprehension>) with func(<generator
  expression>) when supported (e.g. any(), all(), tuple(), min(), &
  max())
2017-05-18 07:35:54 -07:00
Dong-hee Na 378d70642a bpo-30149: Fix partialmethod without explicit self parameter (#1308) 2017-05-17 12:00:51 -07:00
Nate fcfe80ec25 bpo-29822: Make inspect.isabstract() work during __init_subclass__. (#678)
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.
2017-04-24 20:06:15 +03:00
Xiang Zhang a6902e662c bpo-26985: Add missing info of code object in inspect documentation (GH-1090) 2017-04-13 10:38:28 +08:00
Berker Peksag 3f988744b0 Issue #15812: Merge from 3.5 2017-01-03 03:48:34 +03:00
Berker Peksag 225b01b840 Issue #15812: Delete redundant max(start, 0)
Noticed by Serhiy Storchaka.
2017-01-03 03:48:04 +03:00
Berker Peksag 01debaccdd Issue #15812: Merge from 3.5 2017-01-02 06:59:12 +03:00
Berker Peksag ff0e3b7a54 Issue #15812: inspect.getframeinfo() now correctly shows the first line of a context
Patch by Sam Breese.
2017-01-02 06:57:43 +03:00
Nick Coghlan 3c35fdb8fb Issue #27172: Undeprecate inspect.getfullargspec()
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.
2016-12-02 20:29:57 +10:00
Yury Selivanov d8aa0c6eec Merge 3.5 (issue #28639) 2016-11-08 19:59:29 -05:00
Yury Selivanov c0215dfbc1 Issue #28639: Fix inspect.isawaitable to always return bool
Patch by Justin Mayfield.
2016-11-08 19:57:44 -05:00
Yury Selivanov 4778e13148 docs/inspect: clarify iscoroutinefunction; add docs for isasyncgen* 2016-11-08 12:23:09 -05:00
Guido van Rossum 265dce6cbb Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L. (3.5->3.6) 2016-10-22 07:56:58 -07:00
Guido van Rossum 52e5004b59 Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L. 2016-10-22 07:55:18 -07:00
Yury Selivanov eb6364557f Issue #28003: Implement PEP 525 -- Asynchronous Generators. 2016-09-08 22:01:51 -07:00
Martin Panter 0f0eac431f Issue #27993: Fix problems with plural objects in docs and comments 2016-09-07 11:04:41 +00:00
Martin Panter 1aa642f6bd Issue #27993: Merge plural fixes from 3.5 2016-09-07 23:36:43 +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