Skip to content

Commit f82e104

Browse files
committed
Doc updates and tweaks
1 parent 1895600 commit f82e104

File tree

3 files changed

+42
-87
lines changed

3 files changed

+42
-87
lines changed

docs/faq.rst

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,27 @@ Maturity
118118
Is it tested?
119119
-------------
120120

121-
``future`` is used by ``mezzanine`` and ``ObsPy``. It has also been used to
122-
help with the port of 800,000 lines of Python 2 code in Sage to Python 2/3
123-
(currently underway).
121+
``future`` is used by several major projects, including `mezzanine
122+
<http://mezzanine.jupo.org>`_ and `ObsPy <http://www.obspy.org>`_. It is also
123+
currently being used to help with porting 800,000 lines of Python 2 code in
124+
`Sage <http://sagemath.org>`_ to Python 2/3.
124125

125126
Currently ``future`` has 800+ unit tests. Many of these are straight from the
126-
Python 3.3 test suite. In general, the ``future`` package itself is in good
127-
shape, whereas the ``futurize`` script for automatic porting is incomplete and
128-
imperfect. (Chances are it will require some manual cleanup afterwards.) The
129-
``past`` package also needs further work.
130-
127+
Python 3.3 test suite.
128+
129+
In general, the ``future`` package itself is in good shape, whereas the
130+
``futurize`` script for automatic porting is incomplete and imperfect.
131+
(Chances are it will require some manual cleanup afterwards.) The ``past``
132+
package also needs further work.
133+
134+
131135
Is the API stable?
132136
------------------
133137

134-
Not yet; ``future`` is still in beta. We will try not to break anything which
135-
was documented and used to work. After version 1.0 is released, the API will
136-
not change in backward-incompatible ways until a hypothetical version 2.0.
138+
Not yet; ``future`` is still in beta. Where possible, we will try not to break
139+
anything which was documented and used to work. After version 1.0 is released,
140+
the API will not change in backward-incompatible ways until a hypothetical
141+
version 2.0.
137142

138143
..
139144
Are there any example of Python 2 packages ported to Python 3 using ``future`` and ``futurize``?

docs/standard_library_imports.rst

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Standard library imports
66
:mod:`future` supports the standard library reorganization (PEP 3108). Under
77
the standard Python 3 names and locations, it provides access to either the
88
corresponding native standard library modules (``future.moves``) or to backported
9-
modules from Python 3.3 (``future.standard_library``).
9+
modules from Python 3.3 (``future.backports``).
1010

1111
There are currently four interfaces to the reorganized standard library.
1212

@@ -70,7 +70,7 @@ follows::
7070
install_hooks() call
7171
------------------------
7272

73-
The fourth (deprecated) interface to the reorganized standard library is via an
73+
The fourth interface to the reorganized standard library is via an
7474
explicit call to ``install_hooks``::
7575

7676
from future import standard_library
@@ -91,8 +91,8 @@ active indefinitely.)
9191
The call to ``scrub_future_sys_modules()`` removes any modules from the
9292
``sys.modules`` cache (on Py2 only) that have Py3-style names, like ``http.client``.
9393
This can prevent libraries that have their own Py2/3 compatibility code from
94-
importing the ``future.standard_library`` modules unintentionally. Code such as
95-
this will then fall through to using the Py2 standard library
94+
importing the ``future.moves`` or ``future.backports`` modules unintentionally.
95+
Code such as this will then fall through to using the Py2 standard library
9696
modules on Py2::
9797

9898
try:
@@ -101,12 +101,8 @@ modules on Py2::
101101
from httplib import HTTPConnection
102102

103103
**Requests**: The above snippet is from the `requests
104-
<http://docs.python-requests.org>`_ library. Note that ``requests`` is
105-
currently incompatible with the import hooks in ``future.standard_library``. To
106-
use both of these together, you must call ``remove_hooks()`` and
107-
``scrub_future_sys_modules()`` as above before you (or users of your library)
108-
import ``requests``. The easiest way to do this is with the ``hooks`` context
109-
manager or one of the other import mechanisms (see above).
104+
<http://docs.python-requests.org>`_ library. As of v0.12, the
105+
``future.standard_library`` import hooks are compatible with Requests.
110106

111107

112108
.. If you wish to avoid changing every reference of ``http.client`` to
@@ -154,9 +150,11 @@ Backports
154150
---------
155151

156152
Backports of the following modules from Python 3.3's standard library to Python 2.x are also
157-
available in ``future.standard_library``::
153+
available in ``future.backports``::
158154

155+
http.client
159156
http.server
157+
html.server
160158
urllib
161159
xmlrpc.client
162160
xmlrpc.server

docs/whatsnew.rst

Lines changed: 17 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mechanism with 3rd-party modules.
1414
Standard-library import hooks now require explicit installation
1515
---------------------------------------------------------------
1616

17-
*Note: backwards-incompatible change:* As previously announced (see
17+
**Note: backwards-incompatible change:** As previously announced (see
1818
:ref:`deprecated-auto-import-hooks`), the import hooks must now be enabled
1919
explicitly, as follows::
2020

@@ -26,10 +26,12 @@ explicitly, as follows::
2626

2727
This now causes these modules to be imported from ``future.moves``, a new
2828
package that provides wrappers over the native Python 2 standard library with
29-
the new Python 3 organization.
29+
the new Python 3 organization. As a consequence, the import hooks provided in
30+
``future.standard_library`` are now fully compatible with the `Requests library
31+
<http://python-requests.org>`_.
3032

31-
The functional interface is now deprecated but still supported for backwards
32-
compatibility::
33+
The functional interface with ``install_hooks()`` is still supported for
34+
backwards compatibility::
3335

3436
from future import standard_library
3537
standard_library.install_hooks():
@@ -39,49 +41,10 @@ compatibility::
3941
...
4042
standard_library.remove_hooks()
4143

42-
This allows finer-grained control over whether import hooks are enabled for
43-
other imported modules, such as ``requests``, which provide their own Python
44-
2/3 compatibility code. This also improves compatibility of ``future`` with
45-
tools like ``py2exe``.
46-
47-
48-
.. Versioned standard library imports
49-
.. ----------------------------------
50-
..
51-
.. ``future`` now offers a choice of either backported versions of the standard library modules from Python 3.3 or renamed Python 2.7 versions. Use it as follows::
52-
..
53-
.. from future import standard_library
54-
.. standard_library.install_hooks(version='3.3')
55-
.. import html.parser
56-
.. ...
57-
.. standard_library.remove_hooks()
58-
..
59-
.. or as follows::
60-
..
61-
.. from future import standard_library
62-
.. with standard_library.hooks(version='2.7'):
63-
.. import html.parser
64-
.. ...
65-
..
66-
.. If ``version='2.7'`` is selected, on Python 2.7 the import hooks provide an interface to the
67-
.. Python 2.7 standard library modules remapped to their equivalent Python 3.x names. For example, the above code is equivalent to this on Python 2.7 (more or less)::
68-
..
69-
.. import htmllib
70-
.. module = type(htmllib)
71-
.. html = module('html')
72-
.. html.parser = module('html.parser')
73-
.. html.parser.HTMLParser = htmllib.HTMLParser
74-
.. html.parser.HTMLParseError = htmllib.htmlParseError
75-
..
76-
.. but the dozen or so other functions in Python 3.3's ``html.parser`` module are not available on Python 2.7.
77-
..
78-
..
79-
.. If ``version=='3.3'`` is selected,
80-
..
81-
.. These are not (yet) full backports of
82-
.. the Python 3.3
83-
.. modules but remappings to the corresponding
84-
.. functionality in the Python 2.x standard library.
44+
Requiring explicit installation of import hooks allows finer-grained control
45+
over whether they are enabled for other imported modules that provide their own
46+
Python 2/3 compatibility layer. This also improves compatibility of ``future``
47+
with tools like ``py2exe``.
8548

8649

8750
``newobject`` base object defines fallback Py2-compatible special methods
@@ -134,7 +97,7 @@ functions like ``map()`` and ``filter()`` now behave as they do on Py2 with with
13497

13598
The ``past.builtins`` module has also been extended to add Py3 support for
13699
additional Py2 constructs that are not adequately handled by ``lib2to3`` (see
137-
issue #37). This includes custom ``execfile()`` and ``cmp()`` functions.
100+
issue #37). This includes new ``execfile()`` and ``cmp()`` functions.
138101
``futurize`` now invokes imports of these functions from ``past.builtins``.
139102

140103

@@ -454,21 +417,18 @@ Please remember to import ``input`` from ``future.builtins`` if you use
454417
``input()`` in a Python 2/3 compatible codebase.
455418

456419

457-
.. deprecated-auto-import-hooks
420+
.. deprecated-auto-import-hooks:
458421
459422
Deprecated feature: auto-installation of standard-library import hooks
460423
----------------------------------------------------------------------
461424

462425
Previous versions of ``python-future`` installed import hooks automatically upon
463-
``from future import standard_library``. This has been deprecated in order to
464-
improve robustness and compatibility with modules like ``requests`` that already
465-
perform their own single-source Python 2/3 compatibility.
426+
importing the ``standard_library`` module from ``future``. This has been
427+
deprecated in order to improve robustness and compatibility with modules like
428+
``requests`` that already perform their own single-source Python 2/3
429+
compatibility.
466430

467-
.. (Previously, the import hooks were
468-
.. bleeding into surrounding code, causing incompatibilities with modules like
469-
.. ``requests`` (issue #19).
470-
471-
In the next version of ``python-future``, importing ``future.standard_library``
431+
As of v0.12 of ``python-future``, importing ``future.standard_library``
472432
will no longer install import hooks by default. Instead, please install the
473433
import hooks explicitly as follows::
474434
@@ -479,16 +439,8 @@ and uninstall them after your import statements using::
479439

480440
standard_library.remove_hooks()
481441

482-
.. For more fine-grained use of import hooks, the names can be passed explicitly as
483-
.. follows::
484-
..
485-
.. from future import standard_library
486-
.. standard_library.install_hooks()
487-
488-
489442
*Note*: this will be a backward-incompatible change.
490443

491-
.. This feature may be resurrected in a later version if a safe implementation can be found.
492444

493445

494446
Internal changes

0 commit comments

Comments
 (0)