Commit graph

213 commits

Author SHA1 Message Date
Larry Hastings
44e2eaab54 Issue #19674: inspect.signature() now produces a correct signature
for some builtins.
2013-11-23 15:37:55 -08:00
Ethan Furman
b0c84cdaac Issue #19030: final pieces for proper location of various class attributes located in the metaclass.
Okay, hopefully the very last patch for this issue.  :/

I realized when playing with Enum that the metaclass attributes weren't always displayed properly.

New patch properly locates DynamicClassAttributes, virtual class attributes (returned by __getattr__ and friends), and metaclass class attributes (if they are also in the metaclass __dir__ method).

Also had to change one line in pydoc to get this to work.

Added tests in test_inspect and test_pydoc to cover these situations.
2013-10-20 22:37:39 -07:00
Ethan Furman
63c141cacd Close #19030: inspect.getmembers and inspect.classify_class_attrs
Order of search is now:
  1. Try getattr
  2. If that throws an exception, check __dict__ directly
  3. If still not found, walk the mro looking for the eldest class that has
     the attribute (e.g. things returned by __getattr__)
  4. If none of that works (e.g. due to a buggy __dir__, __getattr__, etc.
     method or missing __slot__ attribute), ignore the attribute entirely.
2013-10-18 00:27:39 -07:00
Brett Cannon
0de3f0197b Tweak skipIf message 2013-10-02 10:58:58 -04:00
Brett Cannon
634a8fc042 Try to fix issue #19134 again 2013-10-02 10:25:42 -04:00
Brett Cannon
63f03ed3db Issue #19134: Make a test in inspect conditional on multiprocessing
being available.

Thanks to Remi Pointel for the bug report.
2013-09-30 15:21:09 -04:00
Ethan Furman
e03ea37a7b Close #19030: improvements to inspect and Enum.
inspect.getmembers and inspect.classify_class_attrs now search the metaclass
mro for types.DynamicClassAttributes (what use to be called
enum._RouteClassAttributeToGetattr); in part this means that these two
functions no longer rely solely on dir().

Besides now returning more accurate information, these improvements also
allow a more helpful help() on Enum classes.
2013-09-25 07:14:41 -07:00
Nick Coghlan
f94a16b494 Close #18626: add a basic CLI for the inspect module 2013-09-22 22:46:49 +10:00
Serhiy Storchaka
1e0d82cece Issue #18830: inspect.getclasstree() no more produces duplicated entries even
when input list contains duplicates.
2013-09-05 17:16:12 +03:00
Serhiy Storchaka
362c1b513d Issue #18830: inspect.getclasstree() no more produces duplicated entries even
when input list contains duplicates.
2013-09-05 17:14:32 +03:00
Nick Coghlan
e8c45d6d0e Close #13266: Add inspect.unwrap
Initial patch by Daniel Urban and Aaron Iles
2013-07-28 20:00:01 +10:00
Ezio Melotti
0503de9c83 #17526: merge with 3.3. 2013-03-30 05:19:06 +02:00
Ezio Melotti
1b145927d7 #17526: fix an IndexError raised while passing code without filename to inspect.findsource(). Initial patch by Tyler Doyle. 2013-03-30 05:17:24 +02:00
Antoine Pitrou
64a5562f4c Issue #17071: Signature.bind() now works when one of the keyword arguments is named self. 2013-01-29 21:21:56 +01:00
Antoine Pitrou
bd41d1b14c Issue #17071: Signature.bind() now works when one of the keyword arguments is named `self`. 2013-01-29 21:20:57 +01:00
Andrew Svetlov
f7a17b48d7 Replace IOError with OSError (#16715) 2012-12-25 16:47:37 +02:00
Antoine Pitrou
5d62a61b58 Fix test_inspect messing up with linecache.cache. 2012-07-08 13:48:46 +02:00
Nick Coghlan
6c6e2545cb Properly test the various builtins lookup cases in inspect.getclosurevars 2012-06-23 20:07:39 +10:00
Antoine Pitrou
46cb1ef457 Use non-deprecated speling. 2012-06-23 18:11:59 +02:00
Nick Coghlan
04e2e3f231 Close #15153: Added inspect.getgeneratorlocals to simplify whitebox testing of generator state updates 2012-06-23 19:52:05 +10:00
Nick Coghlan
2f92e54507 Close #13062: Add inspect.getclosurevars to simplify testing stateful closures 2012-06-23 19:39:55 +10:00
Larry Hastings
7c7cbfc00f Issue #15008: Implement PEP 362 "Signature Objects".
Patch by Yury Selivanov.
2012-06-22 15:19:35 -07:00
Antoine Pitrou
d5a1a21a89 Prevent test_inspect from keeping alive a ton of frames and local variables by way of a global variable keeping a reference to a traceback.
Should fix some buildbot failures.
2012-06-17 23:18:07 +02:00
Georg Brandl
802505d05e Merge more test vs hashing-order fixes from 3.2. 2012-02-21 00:34:05 +01:00
Georg Brandl
178e5ea305 Disable an inspect test: it depends on dict ordering which parameter is reported as duplicate. 2012-02-21 00:32:36 +01:00
Antoine Pitrou
af5facc4ca Add part of test_inspect test from 2.7 2012-01-18 17:40:48 +01:00
Antoine Pitrou
0c60381749 Add part of test_inspect test from 2.7 2012-01-18 17:40:18 +01:00
Michael Foord
3ba95f8bd9 Metaclasses with metaclasses with a __dict__ descriptor can no longer trigger code execution with inspect.getattr_static.
Closes issue 11829.
2011-12-22 01:13:37 +00:00
Antoine Pitrou
86a8a9ae98 Issue #1785: Fix inspect and pydoc with misbehaving descriptors.
Also fixes issue #13581: `help(type)` wouldn't display anything.
2011-12-21 09:57:40 +01:00
Michael Foord
a51623b160 Fix inspect.getattr_static to work on modules (again).
Closes issue 11813.
2011-12-18 22:01:40 +00:00
Michael Foord
85530aa1c3 Merge 2011-12-22 01:15:53 +00:00
Antoine Pitrou
12f65d1fef Issue #1785: Fix inspect and pydoc with misbehaving descriptors.
Also fixes issue #13581: `help(type)` wouldn't display anything.
2011-12-21 09:59:49 +01:00
Michael Foord
a699a2d0c1 Merge 3.2 2011-12-18 22:09:27 +00:00
Ezio Melotti
d8b509b192 #13012: use splitlines(keepends=True/False) instead of splitlines(0/1). 2011-09-28 17:37:55 +03:00
Benjamin Peterson
9620cc0463 allow "fake" filenames in findsource (closes #9284)
This allows findsource() to work in doctests.

A patch from Dirkjan Ochtman.
2011-06-11 15:53:11 -05:00
Ezio Melotti
75cbd73666 #11938: Fix duplicated test name in test_inspect. Patch by Andreas Stührk. 2011-04-28 00:59:29 +03:00
Benjamin Peterson
6a2638b163 Correct handling of functions with only kwarg args in getcallargs (closes #11256)
A patch from Daniel Urban.
2011-03-28 17:32:31 -05:00
Michael Foord
dcebe0f2dc Closes issue 11133. Fixes two cases where inspect.getattr_static could trigger code execution 2011-03-15 19:20:44 -04:00
Alexander Belopolsky
f546e7035f Issue4335: Added a test for inspect.getsourcelines with a module without EOL at EOF. 2010-12-02 00:10:11 +00:00
Alexander Belopolsky
2f9a77a389 Reverted unintended change from r86916 2010-12-01 21:55:40 +00:00
Alexander Belopolsky
41e422a4ff Issue #4113: Added custom __repr__ method to functools.partial. 2010-12-01 20:05:49 +00:00
Nick Coghlan
7921b9f210 Issue 10220: switch to using string constants rather than integers for inspect.getgeneratorstate() return values and make debugging friendly str() and repr() for generator states a requirement in the test suite 2010-11-30 06:36:04 +00:00
Nick Coghlan
e0f04659cd Issue #10220: Add inspect.getgeneratorstate(). Initial patch by Rodolpho Eckhardt 2010-11-21 03:44:04 +00:00
Ezio Melotti
b3aedd4862 #9424: Replace deprecated assert* methods in the Python test suite. 2010-11-20 19:04:17 +00:00
Michael Foord
35184edd3d Issue 9732: __class__ no longer checked on objects by getattr_static 2010-11-20 16:58:30 +00:00
Michael Foord
e516265bbc Issue 9732: fetch the method resolution order from the type metaclass directly in getattr_static 2010-11-20 16:40:44 +00:00
Michael Foord
cc7ebb8f69 Issue 9732: remove use of __class__ in inspect.getattr_static and note the mro exception to code execution 2010-11-20 16:20:16 +00:00
Michael Foord
95fc51dfda Issue 9732: addition of getattr_static to the inspect module 2010-11-20 15:07:30 +00:00
R. David Murray
4155f97699 Don't use os.normcase when the result we are expecting is None.
This worked fine on linux but fails on Windows.  That may or may
not be a but in normcase.
2010-06-17 13:23:18 +00:00
R. David Murray
a1b3740d04 Merged revisions 82039 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r82039 | r.david.murray | 2010-06-16 21:36:52 -0400 (Wed, 16 Jun 2010) | 10 lines

  #8720: fix inspect regression by teaching getsourcefile about linecache.

  The fix for issue 4050 caused a regression:  before that fix, source
  lines in the linecache would eventually be found by inspect.  After the
  fix inspect reports an error earlier, and the source isn't found.
  The fix for the fix is to have getsourcefile look in the linecache for
  the file and return the psuedo-filename if the source is there, just as
  it already returns it if there is a PEP 302 loader.
........
2010-06-17 02:04:29 +00:00