[pypy-commit] pypy default: Attempt to fix 75ab5316ff3f. Not 100% sure, but at least all ast tests

arigo noreply at buildbot.pypy.org
Sat Oct 11 13:32:32 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
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
 
 


More information about the pypy-commit mailing list