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
This commit is contained in:
Pablo Galindo 2019-07-30 12:04:01 +01:00 committed by Miss Islington (bot)
parent f35c51d2ea
commit 9211e2fd81
5 changed files with 25 additions and 4 deletions

View file

@ -6,6 +6,7 @@ import operator
import struct
from test import support
from test.support.script_helper import assert_python_failure
from test.support.script_helper import assert_python_ok
#
# First, we test that we can generate trees from valid source fragments,
@ -987,5 +988,13 @@ class OtherParserCase(unittest.TestCase):
with self.assertRaises(TypeError):
parser.expr("a", "b")
class TestDeprecation(unittest.TestCase):
def test_deprecation_message(self):
code = "def f():\n import parser\n\nf()"
rc, out, err = assert_python_ok('-c', code)
self.assertIn(b'<string>:2: DeprecationWarning', err)
if __name__ == "__main__":
unittest.main()