|
1 | 1 | Changes in previous versions |
2 | 2 | **************************** |
3 | 3 |
|
| 4 | +.. _whats-new-0.12.4: |
| 5 | + |
| 6 | +What's new in version 0.12.4 |
| 7 | +============================ |
| 8 | + |
| 9 | +- Fix upcasting behaviour of newint (issue #76). |
| 10 | + |
| 11 | + |
| 12 | +.. _whats-new-0.12.3: |
| 13 | + |
| 14 | +What's new in version 0.12.3 |
| 15 | +============================ |
| 16 | + |
| 17 | +- Add "official Python 3.4 support": Py3.4 is now listed among the PyPI Trove |
| 18 | + classifiers and the tests now run successfully on Py3.4 (issue #67). |
| 19 | + |
| 20 | +- Add backports of ``collections.OrderedDict`` and |
| 21 | + ``collections.Counter`` for Python 2.6 (issue #52). |
| 22 | + |
| 23 | +- Add ``--version`` option for ``futurize`` and ``pasteurize`` scripts |
| 24 | + (issue #57). |
| 25 | + |
| 26 | +- Fix ``future.utils.ensure_new_type`` with ``long`` input (issue #65). |
| 27 | + |
| 28 | +- Remove some false alarms on checks for ambiguous fixer names with |
| 29 | + ``futurize -f ...``. |
| 30 | + |
| 31 | +- Testing fixes: |
| 32 | + - Don't hard-code Python interpreter command in tests (issue #62). |
| 33 | + - Fix deprecated ``unittest`` usage in Py3 (also issue #62). |
| 34 | + - Be explicit about encoding temporary file contents as UTF-8 for |
| 35 | + when LANG=C (e.g. when building an RPM) (issue #63). |
| 36 | + - All undecorated tests are now passing again on Python 2.6, 2.7, 3.3, |
| 37 | + and 3.4 (thanks to Elliott Sales de Andrade). |
| 38 | + |
| 39 | +- Docs: |
| 40 | + - Add list of fixers used by ``futurize`` (issue #58). |
| 41 | + - Add list of contributors to the Credits page. |
| 42 | + |
| 43 | +.. _whats-new-0.12.2: |
| 44 | + |
| 45 | +What's new in version 0.12.2 |
| 46 | +============================ |
| 47 | + |
| 48 | +- Add ``bytes.maketrans()`` method (issue #51). |
| 49 | +- Add support for Python versions between 2.7.0 and 2.7.3 (inclusive) |
| 50 | + (issue #53). |
| 51 | +- Bug fix for ``newlist(newlist([1, 2, 3]))`` (issue #50). |
| 52 | + |
| 53 | + |
| 54 | +.. _whats-new-0.12.1: |
| 55 | + |
| 56 | +What's new in version 0.12.1 |
| 57 | +============================ |
| 58 | + |
| 59 | +- Python 2.6 support: ``future.standard_library`` now isolates the ``importlib`` |
| 60 | + dependency to one function (``import_``) so the ``importlib`` backport may |
| 61 | + not be needed. |
| 62 | + |
| 63 | +- Doc updates |
| 64 | + |
| 65 | + |
| 66 | +.. _whats-new-0.12: |
| 67 | + |
| 68 | +What's new in version 0.12.0 |
| 69 | +============================ |
| 70 | + |
| 71 | +The major new feature in this version is improvements in the support for the |
| 72 | +reorganized standard library (PEP 3108) and compatibility of the import |
| 73 | +mechanism with 3rd-party modules. |
| 74 | + |
| 75 | +More robust standard-library import hooks |
| 76 | +----------------------------------------- |
| 77 | + |
| 78 | +**Note: backwards-incompatible change:** As previously announced (see |
| 79 | +:ref:`deprecated-auto-import-hooks`), the import hooks must now be enabled |
| 80 | +explicitly, as follows:: |
| 81 | + |
| 82 | + from future import standard_library |
| 83 | + with standard_library.hooks(): |
| 84 | + import html.parser |
| 85 | + import http.client |
| 86 | + ... |
| 87 | + |
| 88 | +This now causes these modules to be imported from ``future.moves``, a new |
| 89 | +package that provides wrappers over the native Python 2 standard library with |
| 90 | +the new Python 3 organization. As a consequence, the import hooks provided in |
| 91 | +``future.standard_library`` are now fully compatible with the `Requests library |
| 92 | +<http://python-requests.org>`_. |
| 93 | + |
| 94 | +The functional interface with ``install_hooks()`` is still supported for |
| 95 | +backwards compatibility:: |
| 96 | + |
| 97 | + from future import standard_library |
| 98 | + standard_library.install_hooks(): |
| 99 | + |
| 100 | + import html.parser |
| 101 | + import http.client |
| 102 | + ... |
| 103 | + standard_library.remove_hooks() |
| 104 | + |
| 105 | +Explicit installation of import hooks allows finer-grained control |
| 106 | +over whether they are enabled for other imported modules that provide their own |
| 107 | +Python 2/3 compatibility layer. This also improves compatibility of ``future`` |
| 108 | +with tools like ``py2exe``. |
| 109 | + |
| 110 | + |
| 111 | +``newobject`` base object defines fallback Py2-compatible special methods |
| 112 | +------------------------------------------------------------------------- |
| 113 | + |
| 114 | +There is a new ``future.types.newobject`` base class (available as |
| 115 | +``future.builtins.object``) that can streamline Py3/2 compatible code by |
| 116 | +providing fallback Py2-compatible special methods for its subclasses. It |
| 117 | +currently provides ``next()`` and ``__nonzero__()`` as fallback methods on Py2 |
| 118 | +when its subclasses define the corresponding Py3-style ``__next__()`` and |
| 119 | +``__bool__()`` methods. |
| 120 | + |
| 121 | +This obviates the need to add certain compatibility hacks or decorators to the |
| 122 | +code such as the ``@implements_iterator`` decorator for classes that define a |
| 123 | +Py3-style ``__next__`` method. |
| 124 | + |
| 125 | +In this example, the code defines a Py3-style iterator with a ``__next__`` |
| 126 | +method. The ``object`` class defines a ``next`` method for Python 2 that maps |
| 127 | +to ``__next__``:: |
| 128 | + |
| 129 | + from future.builtins import object |
| 130 | + |
| 131 | + class Upper(object): |
| 132 | + def __init__(self, iterable): |
| 133 | + self._iter = iter(iterable) |
| 134 | + def __next__(self): # note the Py3 interface |
| 135 | + return next(self._iter).upper() |
| 136 | + def __iter__(self): |
| 137 | + return self |
| 138 | + |
| 139 | + assert list(Upper('hello')) == list('HELLO') |
| 140 | + |
| 141 | +``newobject`` defines other Py2-compatible special methods similarly: |
| 142 | +currently these include ``__nonzero__`` (mapped to ``__bool__``) and |
| 143 | +``__long__`` (mapped to ``__int__``). |
| 144 | + |
| 145 | +Inheriting from ``newobject`` on Python 2 is safe even if your class defines |
| 146 | +its own Python 2-style ``__nonzero__`` and ``next`` and ``__long__`` methods. |
| 147 | +Your custom methods will simply override those on the base class. |
| 148 | + |
| 149 | +On Python 3, as usual, ``future.builtins.object`` simply refers to ``builtins.object``. |
| 150 | + |
| 151 | + |
| 152 | +``past.builtins`` module improved |
| 153 | +--------------------------------- |
| 154 | + |
| 155 | +The ``past.builtins`` module is much more compatible with the corresponding |
| 156 | +builtins on Python 2; many more of the Py2 unit tests pass on Py3. For example, |
| 157 | +functions like ``map()`` and ``filter()`` now behave as they do on Py2 with with |
| 158 | +``None`` as the first argument. |
| 159 | + |
| 160 | +The ``past.builtins`` module has also been extended to add Py3 support for |
| 161 | +additional Py2 constructs that are not adequately handled by ``lib2to3`` (see |
| 162 | +issue #37). This includes new ``execfile()`` and ``cmp()`` functions. |
| 163 | +``futurize`` now invokes imports of these functions from ``past.builtins``. |
| 164 | + |
| 165 | + |
| 166 | +``surrogateescape`` error handler |
| 167 | +--------------------------------- |
| 168 | + |
| 169 | +The ``newstr`` type (``future.builtins.str``) now supports a backport of the |
| 170 | +Py3.x ``'surrogateescape'`` error handler for preserving high-bit |
| 171 | +characters when encoding and decoding strings with unknown encodings. |
| 172 | + |
| 173 | + |
| 174 | +``newlist`` type |
| 175 | +---------------- |
| 176 | + |
| 177 | +There is a new ``list`` type in ``future.builtins`` that offers ``.copy()`` and |
| 178 | +``.clear()`` methods like the ``list`` type in Python 3. |
| 179 | + |
| 180 | + |
| 181 | +``listvalues`` and ``listitems`` |
| 182 | +-------------------------------- |
| 183 | + |
| 184 | +``future.utils`` now contains helper functions ``listvalues`` and |
| 185 | +``listitems``, which provide Python 2-style list snapshotting semantics for |
| 186 | +dictionaries in both Python 2 and Python 3. |
| 187 | + |
| 188 | +These came out of the discussion around Nick Coghlan's now-withdrawn PEP 469. |
| 189 | + |
| 190 | +There is no corresponding ``listkeys(d)`` function. Use ``list(d)`` for this case. |
| 191 | + |
| 192 | + |
| 193 | +Tests |
| 194 | +----- |
| 195 | + |
| 196 | +The number of unit tests has increased from 600 to over 800. Most of the new |
| 197 | +tests come from Python 3.3's test suite. |
| 198 | + |
| 199 | + |
| 200 | +Refactoring of ``future.standard_library.*`` -> ``future.backports`` |
| 201 | +-------------------------------------------------------------------- |
| 202 | + |
| 203 | +The backported standard library modules have been moved to ``future.backports`` |
| 204 | +to make the distinction clearer between these and the new ``future.moves`` |
| 205 | +package. |
| 206 | + |
| 207 | + |
| 208 | +Backported ``http.server`` and ``urllib`` modules |
| 209 | +------------------------------------------------- |
| 210 | + |
| 211 | +Alpha versions of backports of the ``http.server`` and ``urllib`` module from |
| 212 | +Python 3.3's standard library are now provided in ``future.backports``. |
| 213 | + |
| 214 | +Use them like this:: |
| 215 | + |
| 216 | + from future.backports.urllib.request import Request # etc. |
| 217 | + from future.backports.http import server as http_server |
| 218 | + |
| 219 | +or with this new interface:: |
| 220 | + |
| 221 | + from future.standard_library import import_, from_import |
| 222 | + |
| 223 | + Request = from_import('urllib.request', 'Request', backport=True) |
| 224 | + http = import_('http.server', backport=True) |
| 225 | + |
| 226 | +.. from future.standard_library.email import message_from_bytes # etc. |
| 227 | +.. from future.standard_library.xmlrpc import client, server |
| 228 | +
|
| 229 | +
|
| 230 | +Internal refactoring |
| 231 | +-------------------- |
| 232 | + |
| 233 | +The ``future.builtins.types`` module has been moved to ``future.types``. |
| 234 | +Likewise, ``past.builtins.types`` has been moved to ``past.types``. The only |
| 235 | +user-visible effect of this is to change ``repr(type(obj))`` for instances |
| 236 | +of these types. For example:: |
| 237 | + |
| 238 | + >>> from future.builtins import bytes |
| 239 | + >>> bytes(b'abc') |
| 240 | + >>> type(b) |
| 241 | + future.types.newbytes.newbytes |
| 242 | + |
| 243 | +instead of:: |
| 244 | + |
| 245 | + >>> type(b) # prior to v0.12 |
| 246 | + future.builtins.types.newbytes.newbytes |
| 247 | + |
| 248 | + |
| 249 | +Bug fixes |
| 250 | +--------- |
| 251 | + |
| 252 | +Many small improvements and fixes have been made across the project. Some highlights are: |
| 253 | + |
| 254 | +- Fixes and updates from Python 3.3.5 have been included in the backported |
| 255 | + standard library modules. |
| 256 | + |
| 257 | +- Scrubbing of the ``sys.modules`` cache performed by ``remove_hooks()`` (also |
| 258 | + called by the ``suspend_hooks`` and ``hooks`` context managers) is now more |
| 259 | + conservative. |
| 260 | + |
| 261 | +.. Is this still true? |
| 262 | +.. It now removes only modules with Py3 names (such as |
| 263 | +.. ``urllib.parse``) and not the corresponding ``future.standard_library.*`` |
| 264 | +.. modules (such as ``future.standard_library.urllib.parse``. |
| 265 | +
|
| 266 | +- The ``fix_next`` and ``fix_reduce`` fixers have been moved to stage 1 of |
| 267 | + ``futurize``. |
| 268 | + |
| 269 | +- ``futurize``: Shebang lines such as ``#!/usr/bin/env python`` and source code |
| 270 | + file encoding declarations like ``# -*- coding=utf-8 -*-`` are no longer occasionally |
| 271 | + displaced by ``from __future__ import ...`` statements. (Issue #10.) |
| 272 | + |
| 273 | +- Improved compatibility with py2exe (`issue #31 <https://github.com/PythonCharmers/python-future/issues/31>`_). |
| 274 | + |
| 275 | +- The ``future.utils.bytes_to_native_str`` function now returns a platform-native string |
| 276 | + object and ``future.utils.native_str_to_bytes`` returns a ``newbytes`` object on Py2. |
| 277 | + (`Issue #47 <https://github.com/PythonCharmers/python-future/issues/47>`_). |
| 278 | + |
| 279 | +- The backported ``http.client`` module and related modules use other new |
| 280 | + backported modules such as ``email``. As a result they are more compliant |
| 281 | + with the Python 3.3 equivalents. |
| 282 | + |
4 | 283 |
|
5 | 284 | .. _whats-new-0.11.4: |
6 | 285 |
|
|
0 commit comments