cython-devel
changeset 1242:e597dcac63ac
Docstring bugfix (#103)
| author | Dag Sverre Seljebotn <dagss@student.matnat.uio.no> |
|---|---|
| date | Fri Oct 17 09:44:59 2008 +0200 (4 years ago) |
| parents | b23f31007194 |
| children | 926aaae7ac28 |
| files | Cython/Compiler/Parsing.py tests/run/r_docstrings.pyx |
line diff
1.1 --- a/Cython/Compiler/Parsing.py Thu Oct 16 20:26:34 2008 -0300
1.2 +++ b/Cython/Compiler/Parsing.py Fri Oct 17 09:44:59 2008 +0200
1.3 @@ -2401,14 +2401,16 @@
1.4
1.5 def p_module(s, pxd, full_module_name):
1.6 pos = s.position()
1.7 +
1.8 + option_comments = p_compiler_directive_comments(s)
1.9 + s.parse_comments = False
1.10 +
1.11 doc = p_doc_string(s)
1.12 if pxd:
1.13 level = 'module_pxd'
1.14 else:
1.15 level = 'module'
1.16
1.17 - option_comments = p_compiler_directive_comments(s)
1.18 - s.parse_comments = False
1.19 body = p_statement_list(s, Ctx(level = level), first_statement = 1)
1.20 if s.sy != 'EOF':
1.21 s.error("Syntax error in statement [%s,%s]" % (
2.1 --- a/tests/run/r_docstrings.pyx Thu Oct 16 20:26:34 2008 -0300
2.2 +++ b/tests/run/r_docstrings.pyx Fri Oct 17 09:44:59 2008 +0200
2.3 @@ -1,4 +1,14 @@
2.4 -__doc__ = u"""# Python 3 gets all of these right ...
2.5 +# Some comments first
2.6 +
2.7 +
2.8 +# More comments
2.9 +
2.10 +'A module docstring'
2.11 +
2.12 +doctest = u"""# Python 3 gets all of these right ...
2.13 + >>> __doc__
2.14 + 'A module docstring'
2.15 +
2.16 >>> f.__doc__
2.17 'This is a function docstring.'
2.18
2.19 @@ -38,7 +48,9 @@
2.20
2.21 import sys
2.22 if sys.version_info[0] >= 3:
2.23 - __doc__ = __doc__.replace(u" u'", u" '")
2.24 + doctest = doctest.replace(u" u'", u" '")
2.25 +
2.26 +__test__ = {"test_docstrings" : doctest}
2.27
2.28 def f():
2.29 u"This is a function docstring."
