limitations.rst 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. limitations of the ``future`` module and differences between Py2 and Py3 that are not (yet) handled
  2. ===================================================================================================
  3. The following attributes on functions in Python 3 are not provided in Python
  4. 2.7:
  5. __func__: see six.get_method_function()
  6. __self__: see six.get_method_self()
  7. __self__.__class__
  8. Limitations of the ``futurize`` script
  9. --------------------------------------
  10. The ``futurize`` script is not yet mature; like ``2to3``, on which it is based,
  11. it makes mistakes. Nevertheless, it should be useful for automatically
  12. performing a lot of the repetitive code-substitution tasks when porting from
  13. Py2 to Py2/3.
  14. Some new Python 3.3 features that cause SyntaxErrors on earlier versions
  15. are not currently handled by the ``futurize`` script. This includes:
  16. - ``yield ... from`` syntax for generators in Py3.3
  17. - ``raise ... from`` syntax for exceptions. (This is simple to fix
  18. manually by creating a temporary variable.)
  19. Also:
  20. - Usage of ``file('myfile', 'w')`` as a synonym for ``open`` doesn't seem
  21. to be converted currently.
  22. - ``isinstance(var, basestring)`` should sometimes be converted to
  23. ``isinstance(var, str) or isinstance(var, bytes)``, or sometimes simply
  24. ``isinstance(var, str)``, depending on the context. Currently it is always
  25. converted to ``isinstance(var, str)``.
  26. - Caveats with bytes indexing!::
  27. b'\x00'[0] != 0
  28. b'\x01'[0] != 1
  29. ``futurize`` does not yet wrap all byte-string literals in a ``bytes()``
  30. call. This is on the to-do list. See :ref:`bytes-object` for more information.
  31. Notes
  32. -----
  33. - Ensure you are using new-style classes on Py2. Py3 doesn't require
  34. inheritance from ``object`` for this, but Py2 does. ``pasteurize``
  35. adds this back in automatically, but ensure you do this too
  36. when writing your classes, otherwise weird breakage when e.g. calling
  37. ``super()`` may occur.