Commits

Philip Jenvey  committed ebff654

fix print with file=None

  • Participants
  • Parent commits 0b275da
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/module/__builtin__/app_io.py

 
 def print_(*args, **kwargs):
     """The new-style print function from py3k."""
-    fp = kwargs.pop("file", sys.stdout)
+    fp = kwargs.pop("file", None)
     if fp is None:
-        return
+        fp = sys.stdout
+        if fp is None:
+            return
     def write(data):
         fp.write(str(data))
     sep = kwargs.pop("sep", None)

File pypy/module/__builtin__/test/test_builtin.py

         out = io.StringIO()
         pr(None, file=out)
         assert out.getvalue() == "None\n"
+        out = sys.stdout = io.StringIO()
+        try:
+            pr("amaury", file=None)
+        finally:
+            sys.stdout = save
+        assert out.getvalue() == "amaury\n"
 
     def test_print_function2(self):
         import builtins