Commit b1d1ab30 authored by Georg Brandl's avatar Georg Brandl

Bug #1441397: The compiler module now recognizes module and function

docstrings correctly as it did in Python 2.4.
parent f8c14d65
...@@ -1382,6 +1382,7 @@ _doc_nodes = [ ...@@ -1382,6 +1382,7 @@ _doc_nodes = [
symbol.testlist, symbol.testlist,
symbol.testlist_safe, symbol.testlist_safe,
symbol.test, symbol.test,
symbol.or_test,
symbol.and_test, symbol.and_test,
symbol.not_test, symbol.not_test,
symbol.comparison, symbol.comparison,
......
...@@ -68,6 +68,14 @@ class CompilerTest(unittest.TestCase): ...@@ -68,6 +68,14 @@ class CompilerTest(unittest.TestCase):
def testDefaultArgs(self): def testDefaultArgs(self):
self.assertRaises(SyntaxError, compiler.parse, "def foo(a=1, b): pass") self.assertRaises(SyntaxError, compiler.parse, "def foo(a=1, b): pass")
def testDocstrings(self):
c = compiler.compile('"doc"', '<string>', 'exec')
self.assert_('__doc__' in c.co_names)
c = compiler.compile('def f():\n "doc"', '<string>', 'exec')
g = {}
exec c in g
self.assertEquals(g['f'].__doc__, "doc")
def testLineNo(self): def testLineNo(self):
# Test that all nodes except Module have a correct lineno attribute. # Test that all nodes except Module have a correct lineno attribute.
filename = __file__ filename = __file__
......
...@@ -52,6 +52,9 @@ Core and builtins ...@@ -52,6 +52,9 @@ Core and builtins
Library Library
------- -------
- Bug #1441397: The compiler module now recognizes module and function
docstrings correctly as it did in Python 2.4.
- Bug #1529297: The rewrite of doctest for Python 2.4 unintentionally - Bug #1529297: The rewrite of doctest for Python 2.4 unintentionally
lost that tests are sorted by name before being run. This rarely lost that tests are sorted by name before being run. This rarely
matters for well-written tests, but can create baffling symptoms if matters for well-written tests, but can create baffling symptoms if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment