From 1e03fffa850e4a7f87af9a0f530152ebad612455 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 22 Apr 2020 13:24:03 -0600 Subject: [PATCH 1/4] Deprecate lib2to3 module in light of PEP 617. --- Doc/library/2to3.rst | 12 +++++++----- Lib/lib2to3/__init__.py | 9 ++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst index eb4c9185f48bf2..f21b05ee7a4e38 100644 --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -9,9 +9,7 @@ of *fixers* to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will handle almost all code. 2to3 supporting library :mod:`lib2to3` is, however, a flexible and generic library, so it is -possible to write your own fixers for 2to3. :mod:`lib2to3` could also be -adapted to custom applications in which Python code needs to be edited -automatically. +possible to write your own fixers for 2to3. .. _2to3-using: @@ -466,9 +464,13 @@ and off individually. They are described here in more detail. -------------- +.. deprecated:: 3.10 + Python 3.9 will switch to a PEG parser (see :pep:`617`), and Python 3.10 may + include new language syntax that is not parsable by lib2to3's LL(1) parser. + The ``lib2to3`` module may be removed from the standard library in a future + Python version. + .. note:: The :mod:`lib2to3` API should be considered unstable and may change drastically in the future. - -.. XXX What is the public interface anyway? diff --git a/Lib/lib2to3/__init__.py b/Lib/lib2to3/__init__.py index ea30561d839798..7de54ca9b02fdc 100644 --- a/Lib/lib2to3/__init__.py +++ b/Lib/lib2to3/__init__.py @@ -1 +1,8 @@ -#empty +import warnings + + +warnings.warn( + "lib2to3 is deprecated and may not be able to parse Python 3.10+", + PendingDeprecationWarning, + stacklevel=2, +) From eeaf6299454a53ef832fa45099be818fdcc80406 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2020 20:55:17 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2020-04-22-20-55-17.bpo-40360.Er8sv-.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2020-04-22-20-55-17.bpo-40360.Er8sv-.rst diff --git a/Misc/NEWS.d/next/Library/2020-04-22-20-55-17.bpo-40360.Er8sv-.rst b/Misc/NEWS.d/next/Library/2020-04-22-20-55-17.bpo-40360.Er8sv-.rst new file mode 100644 index 00000000000000..290dd453bd4ad9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-04-22-20-55-17.bpo-40360.Er8sv-.rst @@ -0,0 +1 @@ +The :mod:`lib2to3` module is pending deprecation due to :pep:`617`. \ No newline at end of file From c511f0481d1b9f869c1d8f613db17da38aa06ec9 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 22 Apr 2020 15:04:49 -0600 Subject: [PATCH 3/4] Add links to other options. --- Doc/library/2to3.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst index f21b05ee7a4e38..1d7bd262872905 100644 --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -468,9 +468,13 @@ and off individually. They are described here in more detail. Python 3.9 will switch to a PEG parser (see :pep:`617`), and Python 3.10 may include new language syntax that is not parsable by lib2to3's LL(1) parser. The ``lib2to3`` module may be removed from the standard library in a future - Python version. + Python version. Consider third-party alternatives such as `LibCST`_ or + `parso`_. .. note:: The :mod:`lib2to3` API should be considered unstable and may change drastically in the future. + +.. _LibCST: https://libcst.readthedocs.io/ +.. _parso: https://parso.readthedocs.io/ From 3b3dd143ee329a8a587f8d49fba007ffa299a733 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 22 Apr 2020 15:29:37 -0600 Subject: [PATCH 4/4] Fix AllTest. --- Lib/lib2to3/__init__.py | 2 +- Lib/test/test___all__.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/lib2to3/__init__.py b/Lib/lib2to3/__init__.py index 7de54ca9b02fdc..4224dffef42957 100644 --- a/Lib/lib2to3/__init__.py +++ b/Lib/lib2to3/__init__.py @@ -2,7 +2,7 @@ warnings.warn( - "lib2to3 is deprecated and may not be able to parse Python 3.10+", + "lib2to3 package is deprecated and may not be able to parse Python 3.10+", PendingDeprecationWarning, stacklevel=2, ) diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index c077881511b8ce..0ba243ee4e74e4 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -17,6 +17,7 @@ def check_all(self, modname): names = {} with support.check_warnings( (".* (module|package)", DeprecationWarning), + (".* (module|package)", PendingDeprecationWarning), ("", ResourceWarning), quiet=True): try: