]> granicus.if.org Git - python/commitdiff
Bug #1441397: The compiler module now recognizes module and function
authorGeorg Brandl <georg@python.org>
Sat, 29 Jul 2006 09:33:26 +0000 (09:33 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 29 Jul 2006 09:33:26 +0000 (09:33 +0000)
docstrings correctly as it did in Python 2.4.

Lib/compiler/transformer.py
Lib/test/test_compiler.py
Misc/NEWS

index 53d30f04af8a189413b6624c42ee9f81b4edb71d..a16dc553c4642631c30b9167afd06a2e345b2fd7 100644 (file)
@@ -1382,6 +1382,7 @@ _doc_nodes = [
     symbol.testlist,
     symbol.testlist_safe,
     symbol.test,
+    symbol.or_test,
     symbol.and_test,
     symbol.not_test,
     symbol.comparison,
index 17f181ee41c2396861a299183ebfef408381bdc0..929a12bb6f2945d30fe49be9dee143b72ae1f8a4 100644 (file)
@@ -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__
index a626d870a2cf77162d884a6e239204dcfa8bf6b9..f3e0c6e5c0f7c9ccd2048ade79c01fc7d97fe314 100644 (file)
--- 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