Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-40360: Deprecate lib2to3 module in light of PEP 617 #19663

Merged
merged 4 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Doc/library/2to3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -466,9 +464,17 @@ 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. 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.

.. XXX What is the public interface anyway?
.. _LibCST: https://libcst.readthedocs.io/
.. _parso: https://parso.readthedocs.io/
9 changes: 8 additions & 1 deletion Lib/lib2to3/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
#empty
import warnings


warnings.warn(
"lib2to3 package is deprecated and may not be able to parse Python 3.10+",
PendingDeprecationWarning,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that we don't use PendingDeprecationWarning any more: https://bugs.python.org/issue36404

stacklevel=2,
)
1 change: 1 addition & 0 deletions Lib/test/test___all__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def check_all(self, modname):
names = {}
with support.check_warnings(
(".* (module|package)", DeprecationWarning),
(".* (module|package)", PendingDeprecationWarning),
("", ResourceWarning),
quiet=True):
try:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The :mod:`lib2to3` module is pending deprecation due to :pep:`617`.