bpo-37268: Add deprecation notice and a DeprecationWarning for the parser module (GH-15017)



Deprecate the parser module and add a deprecation warning triggered on import and a warning block in the documentation.





https://bugs.python.org/issue37268



Automerge-Triggered-By: @pablogsal
diff --git a/Doc/library/parser.rst b/Doc/library/parser.rst
index a302681..c55cd65 100644
--- a/Doc/library/parser.rst
+++ b/Doc/library/parser.rst
@@ -25,11 +25,11 @@
 code fragment as a string because parsing is performed in a manner identical to
 the code forming the application.  It is also faster.
 
-.. note::
+.. warning::
 
-   From Python 2.5 onward, it's much more convenient to cut in at the Abstract
-   Syntax Tree (AST) generation and compilation stage, using the :mod:`ast`
-   module.
+   The parser module is deprecated and will be removed in future versions of
+   Python. For the majority of use cases you can leverage the Abstract Syntax
+   Tree (AST) generation and compilation stage, using the :mod:`ast` module.
 
 There are a few things to note about this module which are important to making
 use of the data structures created.  This is not a tutorial on editing the parse
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 85e254f..273fd2b 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -142,6 +142,10 @@
   Python versions it will raise a :exc:`TypeError` for all floats.
   (Contributed by Serhiy Storchaka in :issue:`37315`.)
 
+* The :mod:`parser` module is deprecated and will be removed in future versions
+  of Python. For the majority of use cases users can leverage the Abstract Syntax
+  Tree (AST) generation and compilation stage, using the :mod:`ast` module.
+
 
 Removed
 =======