Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r73902:27aa8184f00f
Date: 2014-10-11 13:32 +0200
http://bitbucket.org/pypy/pypy/changeset/27aa8184f00f/

Log:    Attempt to fix 75ab5316ff3f. Not 100% sure, but at least all ast
        tests seem to pass, and most callers of getfield(optional=True) seem
        not to expect a real None.

diff --git a/pypy/interpreter/astcompiler/ast.py 
b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -22,9 +22,11 @@
 
 def get_field(space, w_node, name, optional):
     w_obj = w_node.getdictvalue(space, name)
-    if w_obj is None and not optional:
-        raise oefmt(space.w_TypeError,
+    if w_obj is None:
+        if not optional:
+            raise oefmt(space.w_TypeError,
                 "required field \"%s\" missing from %T", name, w_node)
+        w_obj = space.w_None
     return w_obj
 
 
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py 
b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -405,9 +405,11 @@
 
 def get_field(space, w_node, name, optional):
     w_obj = w_node.getdictvalue(space, name)
-    if w_obj is None and not optional:
-        raise oefmt(space.w_TypeError,
+    if w_obj is None:
+        if not optional:
+            raise oefmt(space.w_TypeError,
                 "required field \"%s\" missing from %T", name, w_node)
+        w_obj = space.w_None
     return w_obj
 
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to