This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Better inspect.BlockFinder fixes bug
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: nnorwitz, pobrien, rhettinger
Priority: normal Keywords: patch

Created on 2002-11-06 18:04 by pobrien, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
inspect.patch pobrien, 2002-11-06 18:04 diff -c patch for inspect.py from CVS
Messages (4)
msg41581 - (view) Author: Patrick K. O'Brien (pobrien) Date: 2002-11-06 18:04
inspect.BlockFinder didn't do a good enough job finding  
the end of code blocks. This can be observed by  
running:  
  
>>> import inspect  
>>> import tokenize  
>>> print inspect.getsource(tokenize.TokenError)  
class TokenError(Exception): pass  
  
class StopTokenizing(Exception): pass  
  
def printtoken(type, token, (srow, scol), (erow, ecol),  
line): # for testing  
    print "%d,%d-%d,%d:\t%s\t%s" % \  
        (srow, scol, erow, ecol, tok_name[type],  
repr(token))  
  
>>>   
  
Notice how it picks up extra source code lines. The  
attached patch fixes this problem. There should probably 
be some additional unit tests for this, but I ran out of time 
and energy. 
msg41582 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-11-06 22:41
Logged In: YES 
user_id=33168

Does this fix bug # 595018?  There are a few other inspect
module bugs I think.
msg41583 - (view) Author: Patrick K. O'Brien (pobrien) Date: 2002-11-06 22:55
Logged In: YES 
user_id=179604

Yes, this does fix bug # 595018. I'll look at the other inspect 
module bugs when I've got some spare time. 
msg41584 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-01-19 13:26
Logged In: YES 
user_id=80475

I spent a little time testing this one and checked to make 
sure it didn't clash with my fixes.

Marking as accepted and applying as Lib/inspect 1.41.
History
Date User Action Args
2022-04-10 16:05:49adminsetgithub: 37431
2002-11-06 18:04:06pobriencreate