summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-07-29 09:33:26 (GMT)
committerGeorg Brandl <georg@python.org>2006-07-29 09:33:26 (GMT)
commitedd9b0dfb39daa18c1462665c55bc4ad3d0a0e5d (patch)
tree39405800c37f6bbd79c692a0802476fe0bcca346
parent9fd21e31b6683e532949bbf650bb9decee4f42a4 (diff)
downloadcpython-edd9b0dfb39daa18c1462665c55bc4ad3d0a0e5d.zip
cpython-edd9b0dfb39daa18c1462665c55bc4ad3d0a0e5d.tar.gz
cpython-edd9b0dfb39daa18c1462665c55bc4ad3d0a0e5d.tar.bz2
Bug #1441397: The compiler module now recognizes module and function
docstrings correctly as it did in Python 2.4.
-rw-r--r--Lib/compiler/transformer.py1
-rw-r--r--Lib/test/test_compiler.py8
-rw-r--r--Misc/NEWS3
3 files changed, 12 insertions, 0 deletions
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index 53d30f0..a16dc55 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -1382,6 +1382,7 @@ _doc_nodes = [
symbol.testlist,
symbol.testlist_safe,
symbol.test,
+ symbol.or_test,
symbol.and_test,
symbol.not_test,
symbol.comparison,
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
index 17f181e..929a12b 100644
--- a/Lib/test/test_compiler.py
+++ b/Lib/test/test_compiler.py
@@ -68,6 +68,14 @@ class CompilerTest(unittest.TestCase):
def testDefaultArgs(self):
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):
# Test that all nodes except Module have a correct lineno attribute.
filename = __file__
diff --git a/Misc/NEWS b/Misc/NEWS
index a626d87..f3e0c6e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,9 @@ Core and builtins
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
lost that tests are sorted by name before being run. This rarely
matters for well-written tests, but can create baffling symptoms if