[Tutor] Questions about the deprecation of standard library modules

Mats Wichmann mats at wichmann.us
Sat Mar 30 23:55:04 EDT 2019


On March 30, 2019 9:13:16 PM MDT, boB Stepp <robertvstepp at gmail.com> wrote:
>While reading in chapter 3 of "Learning Python, 5th ed." by Mark Lutz,
>I was playing around with reload() in the imp module.  In the
>interpreter I did a "from imp import reload" and then help(reload).
>This had a warning that it was deprecated.  After a search online I
>found that the entire imp library was deprecated since Python 3.4.
>The aforementioned book covers through Python 3.3.  This got me to
>wondering when the imp module would be removed from Python 3, which
>led me to finding PEP 4.  In it it says:
>
>Module name:   imp
>Rationale:     Replaced by the importlib module.
>Date:          2013-02-10
>Documentation: Deprecated as of Python 3.4.
>
>There is no mention as to _when_ the module might be removed.  PEP 4
>says that a deprecated module may be removed as early as the next
>Python release after it becomes deprecated.  Also the PEP states that
>if a module exists in both Python 2.7 and Python 3.5, it will not be
>removed until Python 2.7 is no longer supported, which, I suppose,
>means next year.
>
>So my main question is how does one know in which Python version a
>deprecated module will be removed?  I'm not too concerned about the
>imp module, but _do_ want to know how the removal process works for
>deprecated standard library modules that I might be interested in.

bob, there's no real answer. if you look at tempfile, it says tempfile.mktemp() is deprecated since 2.3 (2003) and tempfile.template since 2.0 (2000). both still exist and work...  3.7 and much more so 3.8 become a lot more aggressive in warning about deprecated behavior, and the warnings alone can be an issue (a project I work on has its test suite break completely with 3.8 alpha because it tests stdout/stderr being as expected, and the warnings leak into stderr for the tests. yes imp is one of those).   So fix when you have to, I guess, but preferably be proactive and fix earlier... dont count on having X releases.
-- 
Sent from a mobile device with K-9 Mail. Please excuse my brevity.


More information about the Tutor mailing list