[pypy-issue] Issue #1960: print_function behavior different from CPython on file=None (pypy/pypy)

Jim Witschey issues-reply at bitbucket.org
Sat Jan 10 19:45:34 CET 2015


New issue 1960: print_function behavior different from CPython on file=None
https://bitbucket.org/pypy/pypy/issue/1960/print_function-behavior-different-from

Jim Witschey:

The [documentation for the `print` function](https://docs.python.org/3/library/functions.html?highlight=print#print) states:

> The `file` argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used.

In CPython, this behavior holds:

``` bash
$ python2.7 -c "from __future__ import print_function ; print('test', file=None)"
test
```

but it does not in PyPy:

``` bash
$ pypy -c "from __future__ import print_function ; print('test', file=None)"
```

(It's hard to show the absence of something -- note that this doesn't print anything.)

This behavior is implemented correctly in pypy3:

``` bash
$ pypy3 -c "print('test', file=None)"
test
```

Version information:

``` bash
$ pypy --version
Python 2.7.8 (a980ebb26592ed26706cd33a4e05eb45b5d3ea09, Oct 21 2014, 20:15:33)
[PyPy 2.4.0 with GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)]
$ python2.7 --version
Python 2.7.9
```




More information about the pypy-issue mailing list