Python parser bug report and fix

Antille Julien julien.antille at eivd.ch
Sat Jan 31 19:41:03 UTC 2004



Product: Kdevelop
Version : 3.0.0 RC1
Reporter : Julien Antille (julien dot antille at eivd dot ch)


A) Description
KDevelop does not handle docstring correctly. When a multi-line docstring 
starts with the "class" keyword, KDevelop takes it as a real class. 
Docstring is a python string inserted right after a class/method definition, 
used to generate docs. A simple example is :
class MyClass:
	"""
	This is a docstring
	"""
	def __init__(self):
		#some code ...


More information about docstring here : 
http://www.python.org/peps/pep-0287.html

B) How to reproduce
Insert the following code in a .py source in Kdevelop (create a Python script 
project).

#!python

class A:
        """
        This is a comment for the
        class I just created
        """
        def __init__(self):
                pass

def main():
  print 'Hello world!'

main()
#################

Explore the class treeview. You get a class "I".

C) Fix
The attached patch handles this issue and any dogstring-related potential 
problem.  It's a direct patch again pythonsupportpart.cpp (to be applied 
from ./languages/python)


Greetz to the whole team


Julien Antille
julien dot antille at eivd dot ch
Switzerland
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python_parser_fix.diff
Type: text/x-diff
Size: 1357 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20040131/4f71133b/attachment.bin>


More information about the KDevelop-devel mailing list