This release fixes compatibility bugs with CherryPy’s Py2/3 compat layer and
the latest version of the urllib3
package. It also adds some additional
backports for Py2.6 and Py2.7 from Py3.4’s standard library.
New features:
install_aliases()
now exposes full backports of the Py3 urllib submodules
(parse
, request
etc.) from future.backports.urllib
as submodules
of urllib
on Py2. This implies, for example, that
urllib.parse.unquote
now takes an optional encoding argument as it does
on Py3. This improves compatibility with CherryPy’s Py2/3 compat layer (issue
#158).tkinter.ttk
support (issue #151)collections.ChainMap
(issue #150)itertools.count
for Py2.6 (issue #152)surrogateescape
error handler for newstr
and newbytes
objects on Py2.x (issue #116). This feature is currently in alpha.http.client
such as HTTP_PORT
and BAD_REQUEST
(issue #137)reprlib.recursive_repr
to Py2Bug fixes:
HTTPMessage
to http.client
, which is missing from httplib.__all__
on Python <= 2.7.10. This restores compatibility with the latest urllib3
package (issue #159, thanks to Waldemar Kornewald)Counter
and OrderedDict
to use the newer
implementations from Py3.4. This fixes .copy()
preserving subclasses etc.futurize
no longer breaks working Py2 code by changing basestring
to
str
. Instead it imports the basestring
forward-port from
past.builtins
(issues #127 and #156)future.utils
: add string_types
etc. and update docs (issue #126)This is a bug-fix release:
thread
(not dummy_thread
) as _thread
on Py2 (issue #124)newint.to_bytes()
(issue #128)OrderedDict.clear()
on Py2.6 (issue #125)newrange
: equality and slicing, start/stop/step properties, refactoring (issues #129, #130)This is a bug-fix release:
past.translation
(issue #117)html.escape()
: replace function with the more robust one from Py3.4setup.py
(issue #108)install_aliases()
instead of
install_hooks()
iteritems
import error in cheat sheet (issue #120)test.test_support
on Py2 or test.support
on Py3 (issue #109)PYTHONPATH
for tests (PR #111)This is a minor bug-fix release:
test.test_support
module always
exists on Py2 (issue #109)This is a major new release that offers a cleaner interface for most imports in Python 2/3 compatible code.
Instead of this interface:
>>> from future.builtins import str, open, range, dict
>>> from future.standard_library import hooks
>>> with hooks():
... import queue
... import configparser
... import tkinter.dialog
... # etc.
you can now use the following interface for much Python 2/3 compatible code:
>>> # Alias for future.builtins on Py2:
>>> from builtins import str, open, range, dict
>>> # Alias for future.moves.* on Py2:
>>> import queue
>>> import configparser
>>> import tkinter.dialog
>>> etc.
Notice that the above code will run on Python 3 even without the presence of the
future
package. Of the 44 standard library modules that were refactored with
PEP 3108, 30 are supported with direct imports in this manner. (These are listed
here: Direct imports.)
The other 14 standard library modules that kept the same top-level names in
Py3.x are not supported with this direct import interface on Py2. These include
the 5 modules in the Py3 urllib
package. These modules are accessible through
the following interface (as well as the interfaces offered in previous versions
of python-future
):
from future.standard_library import install_aliases
install_aliases()
from collections import UserDict, UserList, UserString
import dbm.gnu
from itertools import filterfalse, zip_longest
from subprocess import getoutput, getstatusoutput
from sys import intern
import test.support
from urllib.request import urlopen
from urllib.parse import urlparse
# etc.
from collections import Counter, OrderedDict # backported to Py2.6
The complete list of packages supported with this interface is here: Aliased imports.
For more information on these and other interfaces to the standard library, see Standard library imports.
future.moves
package to include most of the remaining
modules that were moved in the standard library reorganization (PEP 3108).
(Issue #104).--doctests_only
option from the futurize
and pasteurize
scripts for now (issue #103).The project folder structure has changed. Top-level packages are now in a
src
folder and the tests have been moved into a project-level tests
folder.
The following deprecated internal modules have been removed (issue #80):
future.utils.encoding
and future.utils.six
.The following internal functions have been deprecated and will be removed in a future release:
future.standard_library.scrub_py2_sys_modules
future.standard_library.scrub_future_sys_modules
See Changes in previous versions for versions prior to v0.14.