summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-11-06 03:33:52 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-11-06 03:33:52 (GMT)
commita59ac0a7df57b9081aa08d7e89451e563c58faf9 (patch)
tree442d2be09c87a713759ee4a927f05aa7daa79420
parentd3d7bb1c315eef797dd9ccc952cb232269cb4b49 (diff)
downloadcpython-a59ac0a7df57b9081aa08d7e89451e563c58faf9.zip
cpython-a59ac0a7df57b9081aa08d7e89451e563c58faf9.tar.gz
cpython-a59ac0a7df57b9081aa08d7e89451e563c58faf9.tar.bz2
If a function contains a doc string, remove the doc string node from
the function's body. If assert is used without an error message, make the AST node None rather than Name('None').
-rw-r--r--Lib/compiler/transformer.py6
-rw-r--r--Tools/compiler/compiler/transformer.py6
2 files changed, 10 insertions, 2 deletions
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index a19fb10..f718f88 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -173,6 +173,10 @@ class Transformer:
# code for function
code = self.com_node(nodelist[4])
+ if doc is not None:
+ assert isinstance(code, Stmt)
+ assert isinstance(code.nodes[0], Discard)
+ del code.nodes[0]
n = Function(name, names, defaults, flags, doc, code)
n.lineno = lineno
return n
@@ -400,7 +404,7 @@ class Transformer:
if (len(nodelist) == 4):
expr2 = self.com_node(nodelist[3])
else:
- expr2 = Name('None')
+ expr2 = None
n = Assert(expr1, expr2)
n.lineno = nodelist[0][2]
return n
diff --git a/Tools/compiler/compiler/transformer.py b/Tools/compiler/compiler/transformer.py
index a19fb10..f718f88 100644
--- a/Tools/compiler/compiler/transformer.py
+++ b/Tools/compiler/compiler/transformer.py
@@ -173,6 +173,10 @@ class Transformer:
# code for function
code = self.com_node(nodelist[4])
+ if doc is not None:
+ assert isinstance(code, Stmt)
+ assert isinstance(code.nodes[0], Discard)
+ del code.nodes[0]
n = Function(name, names, defaults, flags, doc, code)
n.lineno = lineno
return n
@@ -400,7 +404,7 @@ class Transformer:
if (len(nodelist) == 4):
expr2 = self.com_node(nodelist[3])
else:
- expr2 = Name('None')
+ expr2 = None
n = Assert(expr1, expr2)
n.lineno = nodelist[0][2]
return n