summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix another problem in inspect: if the module for an object cannot be found, ↵Georg Brandl2006-04-301-1/+5
| | | | don't try to give its __dict__ to linecache.
* Fix infinite regress when inspecting <string> or <stdin> frames.Phillip J. Eby2006-04-301-1/+7
|
* Add whitespace after commaNeal Norwitz2006-04-111-1/+1
|
* Updated the warnings, linecache, inspect, traceback, site, and doctest modulesPhillip J. Eby2006-04-111-3/+3
| | | | | to work correctly with modules imported from zipfiles or via other PEP 302 __loader__ objects. Tests and doc updates are included.
* some more fixes and tests for inspect.getsource(), triggered by crashesArmin Rigo2005-09-251-27/+20
| | | | from the PyPy project as well as the SF bug #1295909.
* Patch #1159931/bug #1143895: inspect.getsource failed when functions,Johannes Gijsbers2005-03-121-5/+5
| | | | | | etc., had comments after the colon, and some other cases. This patch take a simpler approach that doesn't rely on looking for a ':'. Thanks Simon Percivall!
* Apply itemgetter() instead of lambda.Raymond Hettinger2005-03-111-1/+2
|
* Replace list of constants with tuples of constants.Raymond Hettinger2005-02-061-5/+5
|
* Patch #1011890: fix inspect.getsource breaking with line-continuation &Johannes Gijsbers2004-12-121-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | more. Thanks to Simon Percivall! The patch makes changes to inspect.py in two places: * the pattern to match against functions at line 436 is modified: lambdas should be matched even if not preceded by whitespace, as long as "lambda" isn't part of another word. * the BlockFinder class is heavily modified. Changes are: - checking for "def", "class" or "lambda" names before setting self.started to True. Then checking the same line for word characters after the colon (if the colon is on that line). If so, and the line does not end with a line continuation marker, raise EndOfBlock immediately. - adding self.passline to show that the line is to be included and no more checking is necessary on that line. Since a NEWLINE token is not generated when a line continuation marker exists, this allows getsource to continue with these functions even if the following line would not be indented. Also add a bunch of 'quite-unlikely-to-occur-in-real-life-but-working-anyway' tests.
* Import no longer needed.Raymond Hettinger2004-09-201-1/+0
|
* Raymond reminded me to use DSU keySkip Montanaro2004-09-201-2/+1
|
* Sort classes by fully qualified name. In the common case where you areSkip Montanaro2004-09-201-1/+2
| | | | | | displaying a set of classes from one module it doesn't matter, but if you are displaying a large class tree from multiple modules it improves the display to sort by module.name.
* Use __module__ attribute when available instead of using isclass() predicateJohannes Gijsbers2004-09-111-1/+1
| | | | (functions and methods have grown the __module__ attribute too). See bug #570300.
* Patch #1006219: let inspect.getsource show '@' decorators and add tests forJohannes Gijsbers2004-08-181-2/+3
| | | | | this (which are rather ugly, but it'll have to do until test_inspect gets a major overhaul and a conversion to unittest). Thanks Simon Percivall!
* - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)).Matthias Klose2004-08-151-7/+15
|
* 'inspect' was not listing the functions in a module properly if the module wasBrett Cannon2004-08-131-1/+3
| | | | | | | | reached through a symlink (was comparing path of module to path to function and were not matching because of the symlink). os.path.realpath() is now used to solve this discrepency. Closes bug #570300. Thanks Johannes Gijsbers for the fix.
* SF bug #973092: inspect.getframeinfo bug if 'context' is to bigRaymond Hettinger2004-06-151-1/+1
| | | | Make sure the start argument is not negative.
* [Bug #954364] inspect.getframeinfo() sometimes produces incorrect traceback ↵Andrew M. Kuchling2004-06-051-1/+3
| | | | line #s; fix is to look at tb.tb_lineno, not tb.frame.f_lineno. Patch from Robin Becker and me.
* Apply extract functions instead of lambda.Raymond Hettinger2003-12-011-1/+2
|
* Let library modules use the new keyword arguments for list.sort().Raymond Hettinger2003-10-161-1/+1
|
* Whitespace normalization.Tim Peters2003-06-291-1/+1
|
* A bit o' reformatting and removal of non-_getframe currentframe().Jeremy Hylton2003-06-271-19/+14
|
* Fix for SF bug 620190: getargspec() doesn't work with methods.Jeremy Hylton2003-06-271-3/+10
|
* Return None to signal that the module the object was defined in was not ↵Brett Cannon2003-06-151-0/+2
| | | | found when object has no __name__ attr but is needed to figure out location of object.
* Patch #711902: Cause pydoc to show data descriptor __doc__ strings.Martin v. Löwis2003-05-031-0/+10
|
* Make module lookup a little more robust (certain kinds of fiddling toKa-Ping Yee2003-03-281-2/+2
| | | | sys.modules previously produced an exception).
* SF patch #634557: inspect.BlockFinder didn't do a good enough job findingRaymond Hettinger2003-01-191-0/+2
| | | | | | the end of code blocks. Patch contributed by Patrick O'Brien.
* SF bug #661184: inspect.getsource bugRaymond Hettinger2003-01-141-1/+3
| | | | | | | inspect.getsource would crash with one line definitions like: def f(x): return x or f = lambda x: x
* getdoc():Ka-Ping Yee2002-11-301-6/+14
| | | | | | Remove leading whitespace from first line; remove leading and trailing blank lines from docstrings. (Patch 645938 submitted by David Goodger.)
* This is my patchMichael W. Hudson2002-08-151-13/+3
| | | | | | | | [ 587993 ] SET_LINENO killer Remove SET_LINENO. Tracing is now supported by inspecting co_lnotab. Many sundry changes to document and adapt to this change.
* Add encoding declaration.Martin v. Löwis2002-08-041-0/+1
|
* Replaced .keys() with dictionary iteratorsRaymond Hettinger2002-06-021-1/+1
|
* SF 563203. Replaced 'has_key()' with 'in'.Raymond Hettinger2002-06-011-4/+4
|
* Replaced boolean test with is NoneRaymond Hettinger2002-06-011-2/+2
|
* Use types.StringTypes instead of explicit (str, unicode) listMichael W. Hudson2002-05-201-1/+1
|
* Clean up uses of some deprecated features.Fred Drake2002-04-261-2/+2
| | | | Reported by Neal Norwitz on python-dev.
* Fix getcomments() so that it doesn't fail with TypeErrors.Jeremy Hylton2002-03-281-3/+8
| | | | | | | | | It appears that getcomments() can get called for classes defined in C. Since these don't have source code, it can't do anything useful. A function buried many levels deep was raising a TypeError that was not caught. Who knows why this broke...
* tighten up unqualified except in currentframe()Skip Montanaro2002-03-251-2/+2
| | | | see bug 411881
* Use linecache for loading source code. Closes SF patch 490374.Neil Schemenauer2002-03-231-7/+5
|
* SF patch 530070: pydoc regression, from Martin and Guido.Tim Peters2002-03-171-2/+11
| | | | | Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values.
* SF #515015, raise exception if code not found in findsource()Neal Norwitz2002-03-131-0/+1
|
* Get rid of __defined__ and tp_defined -- there's no need toGuido van Rossum2001-10-151-16/+1
| | | | | distinguish __dict__ and __defined__ any more. In the C structure, tp_cache takes its place -- but this hasn't been implemented yet.
* New function classify_class_attrs(). As a number of SF bug reportsTim Peters2001-09-231-0/+85
| | | | | | | | | | | | | | | | | | | point out, pydoc doesn't tell you where class attributes were defined, gets several new 2.2 features wrong, and isn't aware of some new features checked in on Thursday <wink>. pydoc is hampered in part because inspect.py has the same limitations. Alas, I can't think of a way to fix this within the current architecture of inspect/pydoc: it's simply not possible in 2.2 to figure out everything needed just from examining the object you get back from class.attr. You also need the class context, and the method resolution order, and tests against various things that simply didn't exist before. OTOH, knowledge of how to do that is getting quite complex, so doesn't belong in pydoc. classify_class_attrs takes a different approach, analyzing all the class attrs "at once", and returning the most interesting stuff for each, all in one gulp. pydoc needs to be reworked to use this for classes (instead of the current "filter dir(class) umpteen times against assorted predicates" approach).
* Add a function to compute a class's method resolution order. This isTim Peters2001-09-221-0/+18
| | | | | | easy for 2.2 new-style classes, but trickier for classic classes, and different approaches are needed "depending". The function will allow later code to treat all flavors of classes uniformly.
* Ensure that isfunction(obj) and (the new) ismethoddescriptor(obj) neverTim Peters2001-09-201-5/+8
| | | | | both return true. This restores pydoc's ability to deduce argument lists for functions and methods coded in Python.
* After much thrashing, I believe this is a truly minimal patch to teachTim Peters2001-09-201-1/+21
| | | | | pydoc how to do something sensible with 2.2 descriptors. To see the difference, browse __builtin__ via pydoc before and after the patch.
* In a world with a growing number of subclassable types, replaceTim Peters2001-09-161-10/+8
| | | | | | | | type(x) is T tests with isinstance(x, T) Also got rid of a future-generators import, left over from code that wasn't intended to get checked in.
* The first batch of changes recommended by the fixdiv tool. These areGuido van Rossum2001-09-041-1/+1
| | | | | mostly changes of / operators into //. Once or twice I did more or less than recommended.
* Preliminary support for "from __future__ import generators" to enableGuido van Rossum2001-07-151-0/+2
| | | | | | | | the yield statement. I figure we have to have this in before I can release 2.2a1 on Wednesday. Note: test_generators is currently broken, I'm counting on Tim to fix this.
* Turns out Neil didn't intend for *all* of his gen-branch work to getTim Peters2001-06-291-19/+23
| | | | | | | | | | | | | | | | | | | | committed. tokenize.py: I like these changes, and have tested them extensively without even realizing it, so I just updated the docstring and the docs. tabnanny.py: Also liked this, but did a little code fiddling. I should really rewrite this to *exploit* generators, but that's near the bottom of my effort/benefit scale so doubt I'll get to it anytime soon (it would be most useful as a non-trivial example of ideal use of generators; but test_generators.py has already grown plenty of food-for-thought examples). inspect.py: I'm sure Ping intended for this to continue running even under 1.5.2, so I reverted this to the last pre-gen-branch version. The "bugfix" I checked in in-between was actually repairing a bug *introduced* by the conversion to generators, so it's OK that the reverted version doesn't reflect that checkin.