[Python-checkins] CVS: python/dist/src/Lib inspect.py,1.12,1.13

Ka-Ping Yee ping@users.sourceforge.net
2001年4月12日 06:17:19 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv26252
Modified Files:
	inspect.py 
Log Message:
Robustify getcomments() so it doesn't crash on empty files.
Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** inspect.py	2001年04月10日 11:43:00	1.12
--- inspect.py	2001年04月12日 13:17:17	1.13
***************
*** 306,313 ****
 # Look for a comment block at the top of the file.
 start = 0
! if lines[0][:2] == '#!': start = 1
 while start < len(lines) and string.strip(lines[start]) in ['', '#']:
 start = start + 1
! if lines[start][:1] == '#':
 comments = []
 end = start
--- 306,313 ----
 # Look for a comment block at the top of the file.
 start = 0
! if lines and lines[0][:2] == '#!': start = 1
 while start < len(lines) and string.strip(lines[start]) in ['', '#']:
 start = start + 1
! if start < len(lines) and lines[start][:1] == '#':
 comments = []
 end = start

AltStyle によって変換されたページ (->オリジナル) /