classification
Title: [Python 3.10] Remove APIs deprecated long enough
Type: Stage: patch review
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, hroncok, methane, miss-islington, xtreak
Priority: normal Keywords: easy, patch

Created on 2020-06-30 04:53 by methane, last changed 2020-07-06 03:25 by miss-islington.

Pull Requests
URL Status Linked Edit
PR 21273 closed methane, 2020-07-02 04:38
PR 21276 closed methane, 2020-07-02 06:24
PR 21309 merged methane, 2020-07-04 01:07
PR 21345 merged miss-islington, 2020-07-06 02:48
Messages (13)
msg372653 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-06-30 04:53
I don't think we need to remove them all at onece. But we can remove some of them for code health.

c-api/module.rst

.. c:function:: const char* PyModule_GetFilename(PyObject *module)
   .. deprecated:: 3.2

c-api/init.rst

.. c:function:: void PyEval_AcquireLock()
   .. deprecated:: 3.2

.. c:function:: void PyEval_ReleaseLock()
   .. deprecated:: 3.2

unittest:

   .. deprecated:: 3.1
         The fail* aliases listed in the second column have been deprecated.
   .. deprecated:: 3.2
         The assert* aliases listed in the third column have been deprecated.
   .. deprecated:: 3.2
         ``assertRegexpMatches`` and ``assertRaisesRegexp`` have been renamed to
         :meth:`.assertRegex` and :meth:`.assertRaisesRegex`.

urllib.request:

.. class:: URLopener(proxies=None, **x509)
   .. deprecated:: 3.3
.. class:: FancyURLopener(...)
   .. deprecated:: 3.3

turtle:
.. function:: settiltangle(angle)
   .. deprecated:: 3.1

imp:
.. function:: get_suffixes()
.. function:: find_module(name[, path])
.. function:: load_module(name, file, pathname, description)
.. data:: PY_SOURCE
.. data:: PY_COMPILED
.. data:: C_EXTENSION
.. data:: PKG_DIRECTORY
.. data:: C_BUILTIN
.. data:: PY_FROZEN

configparser:
   .. method:: readfp(fp, filename=None)
      .. deprecated:: 3.2

email.errors:

* :class:`MalformedHeaderDefect` -- A header was found that was missing a colon,
  or was otherwise malformed.

  .. deprecated:: 3.3

pkgutil:
.. class:: ImpImporter(dirname=None)
   .. deprecated:: 3.3
.. class:: ImpLoader(fullname, file, filename, etc)
   .. deprecated:: 3.3

zipfile:
.. exception:: BadZipfile

   Alias of :exc:`BadZipFile`, for compatibility with older Python versions.

   .. deprecated:: 3.2

inspect:
.. function:: getargspec(func)
   .. deprecated:: 3.0

asyncore:
      .. deprecated:: 3.2

importlib:
.. class:: Finder
   .. deprecated:: 3.3

    .. method:: path_mtime(path)
        .. deprecated:: 3.3
msg372654 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-06-30 05:10
PyModule_GetFilename, PyEval_AcquireLock, PyEval_ReleaseLock.
Are they part of stable ABI?
msg372804 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-07-02 06:18
Unittest aliases are deprecated in #9424.
Can we remove them in Python 3.10?
msg372814 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-07-02 07:20
I'm all in favor to remove deprecated things, but please set a tangible deadline first. A lot of these functions have been deprecated for like a decade. Users tend to forget about deprecations or assume that removal was never going to happen. For example the removal of xml.etree.cElementTree broke a bunch of stuff although it had been deprecated since 3.0.

At a bare minimum you should list removed features in the 3.9 changelog and porting guide as "will be removed in 3.10". I would even argue to add deprecation warnings to the code in 3.9 (with permission from the RM). If the RM is against deprecation warnings, then it might be good idea to postpone removal to 3.11.
msg372821 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-07-02 08:00
I don't propose adding DeprecationWarning in 3.9 in this issue.
I don't propose removing functions that don't emit DeprecationWarning.

My first message is just a starting point. I don't propose to remove them all.
msg372823 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-07-02 08:02
For the record, I noticed DeprecationWarning is not shown by unittest.runner by default.

For example, https://travis-ci.org/github/necaris/python3-openid/jobs/703119609

So deprecated aliases should be not removed in 3.10.
msg372828 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-07-02 08:55
I found most of deprecated items in my first comment are aliving by difficult reasons.

I grepped top 4000 packages and found some candidates to deprecate.


## turtle

* settiltangle is not used anywhere.
* tiltangle is also deprecated by docstring, but not in the document.
* Both methods don't emit DeprecationWarning.

TODO(easy): Update the document and emit DeprecationWarning


## email.errors

MalformedHeaderDefect is not used anywhere in top4000 packages.

But it is simple alias, and DeprecationWarning is not emit.

TODO(easy): Emit DeprecationWarning using module __getattr__.


## importlib

abc.SourceLoader.path_mtime is not used anywhere.

TODO: Remove path_mtime from the ABC and raise DeprecationWarning if path_mtime is defined in subclass in path_stats.

---

importlib should be checked by experts.  I keep TODO(easy) for new contributors.
msg372830 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-07-02 09:02
> For the record, I noticed DeprecationWarning is not shown by unittest.runner by default.

There is an open issue for this but I think it's enabled by default https://bugs.python.org/issue39892

$ cat /tmp/test_bar.py
import unittest
import warnings


class TestFoo(unittest.TestCase):

    def test_foo(self):
        self.assertEquals(1, 1)


if __name__ == "__main__":
    unittest.main()

$ python3.8 -m unittest test_bar
/private/tmp/test_bar.py:8: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(1, 1)
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
msg372901 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-07-03 03:14
Hmm.  You are right. The warnings are shown by default.

On the other hand, some project uses custom `setup.py test` command. It hides the DeprecationWarning.

https://github.com/warner/python-ed25519/blob/master/setup.py
https://github.com/warner/python-ed25519/blob/master/src/ed25519/test_ed25519.py#L42

How about emitting FutureWarning instead of DeprecationWarning?

DeprecationWarning is hidden to avoid end users see noisy warnings.
But test is for developers, not end users.
msg372913 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-07-03 09:07
As we discussed in ML, PyEval_ReleaseLock is still used and removing may be not simple. Keep it as-is until Python 4.0.
msg373034 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-07-05 15:30
Adding Miro since Fedora will be testing Python 3.10 and deprecated API removals here might potentially affect libraries like Python 3.9 testing.
msg373066 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-07-06 02:48
New changeset 9ce8132e1f2339cfe116dfd4795574182c2245b4 by Inada Naoki in branch 'master':
bpo-41165: Deprecate PyEval_ReleaseLock() (GH-21309)
https://github.com/python/cpython/commit/9ce8132e1f2339cfe116dfd4795574182c2245b4
msg373067 - (view) Author: miss-islington (miss-islington) Date: 2020-07-06 03:25
New changeset 1ce59f0421d9550762977454bda22db750aa20aa by Miss Islington (bot) in branch '3.9':
bpo-41165: Deprecate PyEval_ReleaseLock() (GH-21309)
https://github.com/python/cpython/commit/1ce59f0421d9550762977454bda22db750aa20aa
History
Date User Action Args
2020-07-06 03:25:22miss-islingtonsetmessages: + msg373067
2020-07-06 02:48:58miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request20493
2020-07-06 02:48:38methanesetmessages: + msg373066
2020-07-05 15:30:48xtreaksetnosy: + hroncok
messages: + msg373034
2020-07-04 01:07:47methanesetkeywords: + patch
pull_requests: + pull_request20461
2020-07-03 09:07:40methanesetmessages: + msg372913
2020-07-03 03:14:45methanesetmessages: + msg372901
2020-07-02 09:02:26xtreaksetmessages: + msg372830
2020-07-02 08:55:33methanesetkeywords: - patch

messages: + msg372828
2020-07-02 08:31:24xtreaksetnosy: + xtreak
2020-07-02 08:02:45methanesetmessages: + msg372823
2020-07-02 08:00:04methanesetmessages: + msg372821
2020-07-02 07:20:40christian.heimessetnosy: + christian.heimes
messages: + msg372814
2020-07-02 06:38:46methanesettitle: [Python 3.10] Remove APIs deprecated since Python 3.3 -> [Python 3.10] Remove APIs deprecated long enough
2020-07-02 06:24:40methanesetpull_requests: + pull_request20425
2020-07-02 06:21:33methanesetkeywords: + easy
2020-07-02 06:18:53methanesetmessages: + msg372804
2020-07-02 04:38:46methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request20423
2020-06-30 05:10:32methanesetmessages: + msg372654
2020-06-30 04:53:16methanecreate