Author: Philip Jenvey <pjen...@underboss.org>
Branch: py3k
Changeset: r73072:f82f65bb5aec
Date: 2014-08-26 11:03 -0700
http://bitbucket.org/pypy/pypy/changeset/f82f65bb5aec/

Log:    fix generic extraction of optional fields

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
@@ -153,7 +153,10 @@
         elif field.type.value in ("bool",):
             return "space.bool_w(%s)" % (value,)
         else:
-            return "%s.from_object(space, %s)" % (field.type, value)
+            extractor = "%s.from_object(space, %s)" % (field.type, value)
+            if field.opt:
+                extractor += " if %s is not None else None" % (value,)
+            return extractor
 
     def get_field_converter(self, field):
         if field.seq:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to