Source text — English
Translation — Bahasa Indonesia
The public-facing changes from the PEP are entirely backward-compatible. Furthermore, they should be transparent to everyone but importer authors. Key finder and loader methods have been deprecated, but they will continue working. New importers should use the new methods described in the PEP. Existing importers should be updated to implement the new methods. See the :ref:`deprecated-3.4` section for a list of methods that should be replaced and their replacements.
The *digestmod* argument to the :func:`hmac.new` function may now be any hash digest name recognized by :mod:`hashlib`. In addition, the current behavior in which the value of *digestmod* defaults to ``MD5`` is deprecated: in a future version of Python there will be no default value. (Contributed by Christian Heimes in :issue:`17276`.)
The *strict* argument of :class:`~html.parser.HTMLParser` is now deprecated. (Contributed by Ezio Melotti in :issue:`15114`.)
:mod:`importlib.util` now has a :const:`~importlib.util.MAGIC_NUMBER` attribute providing access to the bytecode version number. This replaces the :func:`!get_magic` function in the deprecated :mod:`!imp` module. (Contributed by Brett Cannon in :issue:`18192`.)
New :mod:`importlib.util` functions :func:`~importlib.util.cache_from_source` and :func:`~importlib.util.source_from_cache` replace the same-named functions in the deprecated :mod:`!imp` module. (Contributed by Brett Cannon in :issue:`18194`.)
:mod:`plistlib` now has an API that is similar to the standard pattern for stdlib serialization protocols, with new :func:`~plistlib.load`, :func:`~plistlib.dump`, :func:`~plistlib.loads`, and :func:`~plistlib.dumps` functions. (The older API is now deprecated.) In addition to the already supported XML plist format (:const:`~plistlib.FMT_XML`), it also now supports the binary plist format (:const:`~plistlib.FMT_BINARY`). (Contributed by Ronald Oussoren and others in :issue:`14455`.)
Deprecated
Usang
This section covers various APIs and other features that have been deprecated in Python 3.4, and will be removed in Python 3.5 or later. In most (but not all) cases, using the deprecated APIs will produce a :exc:`DeprecationWarning` when the interpreter is run with deprecation warnings enabled (for example, by using ``-Wd``).
As mentioned in :ref:`whatsnew-pep-451`, a number of :mod:`importlib` methods and functions are deprecated: :meth:`!importlib.find_loader` is replaced by :func:`importlib.util.find_spec`; :meth:`!importlib.machinery.PathFinder.find_module` is replaced by :meth:`importlib.machinery.PathFinder.find_spec`; :meth:`!importlib.abc.MetaPathFinder.find_module` is replaced by :meth:`importlib.abc.MetaPathFinder.find_spec`; :meth:`!importlib.abc.PathEntryFinder.find_loader` and :meth:`!find_module` are replaced by :meth:`importlib.abc.PathEntryFinder.find_spec`; all of the :samp:`{xxx}Loader` ABC ``load_module`` methods (``importlib.abc.Loader.load_module``, ``importlib.abc.InspectLoader.load_module``, ``importlib.abc.FileLoader.load_module``, ``importlib.abc.SourceLoader.load_module``) should no longer be implemented, instead loaders should implement an ``exec_module`` method (:meth:`importlib.abc.Loader.exec_module`, :meth:`importlib.abc.InspectLoader.exec_module` :meth:`importlib.abc.SourceLoader.exec_module`) and let the import system take care of the rest; and :meth:`!importlib.abc.Loader.module_repr`, :meth:`!importlib.util.module_for_loader`, :meth:`!importlib.util.set_loader`, and :meth:`!importlib.util.set_package` are no longer needed because their functions are now handled automatically by the import system.
``MD5`` as the default *digestmod* for the :func:`hmac.new` function is deprecated. Python 3.6 will require an explicit digest name or constructor as *digestmod* argument.
The internal ``Netrc`` class in the :mod:`ftplib` module has been documented as deprecated in its docstring for quite some time. It now emits a :exc:`DeprecationWarning` and will be removed completely in Python 3.5.
The undocumented *endtime* argument to :meth:`subprocess.Popen.wait` should not have been exposed and is hopefully not in use; it is deprecated and will mostly likely be removed in Python 3.5.
The *strict* argument of :class:`~html.parser.HTMLParser` is deprecated.
The :mod:`plistlib` :func:`!readPlist`, :func:`!writePlist`, :func:`!readPlistFromBytes`, and :func:`!writePlistToBytes` functions are deprecated in favor of the corresponding new functions :func:`~plistlib.load`, :func:`~plistlib.dump`, :func:`~plistlib.loads`, and :func:`~plistlib.dumps`. :func:`!Data` is deprecated in favor of just using the :class:`bytes` constructor.
The :mod:`sysconfig` key ``SO`` is deprecated, it has been replaced by ``EXT_SUFFIX``.
The ``U`` mode accepted by various ``open`` functions is deprecated. In Python3 it does not do anything useful, and should be replaced by appropriate uses of :class:`io.TextIOWrapper` (if needed) and its *newline* argument.
The *parser* argument of :func:`xml.etree.ElementTree.iterparse` has been deprecated, as has the *html* argument of :func:`~xml.etree.ElementTree.XMLParser`. To prepare for the removal of the latter, all arguments to ``XMLParser`` should be passed by keyword.
Deprecated Features
Running :ref:`idle` with the ``-n`` flag (no subprocess) is deprecated. However, the feature will not be removed until :issue:`18823` is resolved.
The site module adding a "site-python" directory to sys.path, if it exists, is deprecated (:issue:`19375`).
The following obsolete and previously deprecated APIs and features have been removed:
The deprecated :mod:`urllib.request.Request` getter and setter methods ``add_data``, ``has_data``, ``get_data``, ``get_type``, ``get_host``, ``get_selector``, ``set_proxy``, ``get_origin_req_host``, and ``is_unverifiable`` have been removed (use direct attribute access instead).
Support for loading the deprecated ``TYPE_INT64`` has been removed from :mod:`marshal`. (Contributed by Dan Riti in :issue:`15480`.)
:meth:`object.__format__` no longer accepts non-empty format strings, it now raises a :exc:`TypeError` instead. Using a non-empty string has been deprecated since Python 3.2. This change has been made to prevent a situation where previously working (but incorrect) code would start failing if an object gained a __format__ method, which means that your code may now raise a :exc:`TypeError` if you are using an ``'s'`` format code with objects that do not have a __format__ method that handles it. See :issue:`7994` for background.
:meth:`!difflib.SequenceMatcher.isbjunk` and :meth:`!difflib.SequenceMatcher.isbpopular` were deprecated in 3.2, and have now been removed: use ``x in sm.bjunk`` and ``x in sm.bpopular``, where *sm* is a :class:`~difflib.SequenceMatcher` object (:issue:`13248`).
Calling :func:`sysconfig.get_config_var` with the ``SO`` key, or looking ``SO`` up in the results of a call to :func:`sysconfig.get_config_vars` is deprecated. This key should be replaced by ``EXT_SUFFIX`` or ``SHLIB_SUFFIX``, depending on the context (:issue:`19555`).