From: Dag Sverre Seljebotn Date: Fri, 17 Oct 2008 07:44:59 +0000 (+0200) Subject: Docstring bugfix (#103) X-Git-Tag: 0.9.9.2.beta~36 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b3bbfb4c2e084d702214431dafce2c0a4b57f985;p=cython.git Docstring bugfix (#103) --- diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 8ef8277a..45fa1015 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -2401,14 +2401,16 @@ def p_compiler_directive_comments(s): def p_module(s, pxd, full_module_name): pos = s.position() + + option_comments = p_compiler_directive_comments(s) + s.parse_comments = False + doc = p_doc_string(s) if pxd: level = 'module_pxd' else: level = 'module' - option_comments = p_compiler_directive_comments(s) - s.parse_comments = False body = p_statement_list(s, Ctx(level = level), first_statement = 1) if s.sy != 'EOF': s.error("Syntax error in statement [%s,%s]" % ( diff --git a/tests/run/r_docstrings.pyx b/tests/run/r_docstrings.pyx index 60508fbe..00a9fdad 100644 --- a/tests/run/r_docstrings.pyx +++ b/tests/run/r_docstrings.pyx @@ -1,4 +1,14 @@ -__doc__ = u"""# Python 3 gets all of these right ... +# Some comments first + + +# More comments + +'A module docstring' + +doctest = u"""# Python 3 gets all of these right ... + >>> __doc__ + 'A module docstring' + >>> f.__doc__ 'This is a function docstring.' @@ -38,7 +48,9 @@ Compare with standard Python: import sys if sys.version_info[0] >= 3: - __doc__ = __doc__.replace(u" u'", u" '") + doctest = doctest.replace(u" u'", u" '") + +__test__ = {"test_docstrings" : doctest} def f(): u"This is a function docstring."