From 52f5528cfb6d1152ee226e268247dc685a8ba329 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Thu, 8 Nov 2018 15:27:30 +0000 Subject: [REF] *: replace deprecated pycompat helpers for builtins This commit replaces calls to pycompat helpers that were intended for python 2 <-> python 3 interoperability for python 3 builtins, as python 2 is no longer officially supported by Odoo. This includes: * calls to imap/izip/ifilter replaced by map/zip/filter * uses of text_type replaced by str * uses of unichr replaced by chr * calls to implements_to_string, implements_iterator removed * string_types and integer_types replaced by str, int respectively * calls to to_native replaced by calls to to_text This is done in preparation to the removal of these deprecated helpers in the following commit. --- doc/python3.rst | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'doc/python3.rst') diff --git a/doc/python3.rst b/doc/python3.rst index 88475d7dc4a..ac24983ceb7 100644 --- a/doc/python3.rst +++ b/doc/python3.rst @@ -299,8 +299,6 @@ under the single ``int`` type. * the ``L`` suffix for integer literals must be removed * calls to ``long`` must be replaced by calls to ``int`` - * ``(int, long)`` for type-checking purposes must be replaced by - :py:data:`odoo.tools.pycompat.integer_types` * the ``L`` suffix on numbers is unsupported in Python 3, and unnecessary in @@ -311,18 +309,6 @@ under the single ``int`` type. subtype of ``int`` (nor the reverse), and ``isinstance(value, (int, long))`` is thus generally necessary to catch all integrals. - For that case, Odoo 11 now provides a compatibility module with an - :py:data:`~odoo.tools.pycompat.integer_types` definition which can be used - for type-testing. - - It is a tuple of types so when used with ``isinstance`` it can be provided - directly or inside an other tuple alongside other types e.g. - ``isinstance(value, (BaseModel, integer_types))``. - - However when used with ``type`` directly (which should be avoided) you - should use the ``in`` operator, and if you need other types you need to - concatenate ``integer_types`` to an other tuple. - ``reduce`` ########## @@ -411,18 +397,6 @@ Both versions have the following prefixes for string literals: For best cross-version compatibility you should avoid unprefixed string literals unless you *specifically* need a "native string" [#native-string]_. -For easier type-testing, :mod:`odoo.tools.pycompat` provides the following -constants: - -* :data:`~odoo.tools.pycompat.string_types` is an alias/type tuple for testing - string types, essentially a replacement of testing for ``basestring`` or - ``(str, unicode)``. -* :data:`~odoo.tools.pycompat.text_type` is the proper *text* type for the - current version, it should mostly be used for converting non-bytes objects - to text. -* ``bytes`` should be avoided for type conversions, though it can be used to - check if an object is a bytestring. - ``open`` -------- -- cgit v1.2.3