@@ -8,19 +8,19 @@ contents as (unicode) strings unless the binary (``b``) flag is passed, as in::
88
99 open(filename, 'rb')
1010
11- in which case it returns a Py3 :class: `bytes ` object .
12-
13- ``future.builtins `` provides a compatible ``open `` function on Py2,
14- which uses the `` open `` backport available in the standard library :mod: ` io `
15- module on Py2.6+.
16-
17- When porting code from Python 2, be aware of the different return types from
18- methods such as :func: ` read() ` from the file object that ``open `` returns.
19-
20- Note that the output of :func: `read() ` etc. is not automatically cast to the
21- appropriate ``future.builtins.bytes `` or `` future.builtins.str `` type. If you
22- need the stricter type-checking of Py3 on Py2 as well, you can cast it
23- explicitly as follows::
11+ in which case its methods like :func: ` read ` return Py3 :class: `bytes ` objects .
12+
13+ ``future.builtins `` provides an ``open `` function on Py2 that is mostly
14+ compatible with that on Python 3 (e.g. it offers keyword arguments like
15+ `` encoding ``). This maps to the `` open `` backport available in the standard
16+ library :mod: ` io ` module on Py2.6 and Py2.7.
17+
18+ One difference to be aware of between the Python 3 ``open `` and
19+ `` future.builtins.open `` on Python 2 is that the return types of methods such
20+ as :func: `read() ` from the file object that `` open `` returns are not
21+ automatically cast to the appropriate ``future.builtins.bytes `` or
22+ `` future.builtins.str `` types. If you need the returned data to behave the same
23+ way on Py2 as on Py3, you can cast it explicitly as follows::
2424
2525 from __future__ import unicode_literals
2626 from future.builtins import *
0 commit comments