bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)

* Rename PyConfig.use_peg to _use_peg_parser
* Document PyConfig._use_peg_parser and mark it a deprecated
* Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated
  in the documentation.
* Add use_old_parser() and skip_if_new_parser() to test.support
* Remove sys.flags.use_peg: use_old_parser() uses
  _testinternalcapi.get_configs() instead.
* Enhance test_embed tests
* subprocess._args_from_interpreter_flags() copies -X oldparser
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 1888335..ce3561e 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -816,12 +816,12 @@
     if (str == NULL)
         goto error;
 
-    int current_use_peg = PyInterpreterState_Get()->config.use_peg;
+    int current_use_peg = PyInterpreterState_Get()->config._use_peg_parser;
     if (flags & PyCF_TYPE_COMMENTS || feature_version >= 0) {
-        PyInterpreterState_Get()->config.use_peg = 0;
+        PyInterpreterState_Get()->config._use_peg_parser = 0;
     }
     result = Py_CompileStringObject(str, filename, start[compile_mode], &cf, optimize);
-    PyInterpreterState_Get()->config.use_peg = current_use_peg;
+    PyInterpreterState_Get()->config._use_peg_parser = current_use_peg;
     Py_XDECREF(source_copy);
     goto finally;
 
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 7662d61..58cca56 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -635,7 +635,7 @@
 #ifdef MS_WINDOWS
     config->legacy_windows_stdio = -1;
 #endif
-    config->use_peg = 1;
+    config->_use_peg_parser = 1;
 }
 
 
@@ -793,7 +793,7 @@
     COPY_ATTR(isolated);
     COPY_ATTR(use_environment);
     COPY_ATTR(dev_mode);
-    COPY_ATTR(use_peg);
+    COPY_ATTR(_use_peg_parser);
     COPY_ATTR(install_signal_handlers);
     COPY_ATTR(use_hash_seed);
     COPY_ATTR(hash_seed);
@@ -897,7 +897,7 @@
     SET_ITEM_INT(isolated);
     SET_ITEM_INT(use_environment);
     SET_ITEM_INT(dev_mode);
-    SET_ITEM_INT(use_peg);
+    SET_ITEM_INT(_use_peg_parser);
     SET_ITEM_INT(install_signal_handlers);
     SET_ITEM_INT(use_hash_seed);
     SET_ITEM_UINT(hash_seed);
@@ -1434,7 +1434,7 @@
 
     if (config_get_env(config, "PYTHONOLDPARSER")
        || config_get_xoption(config, L"oldparser")) {
-        config->use_peg = 0;
+        config->_use_peg_parser = 0;
     }
 
     PyStatus status;
@@ -2516,7 +2516,7 @@
     assert(config->isolated >= 0);
     assert(config->use_environment >= 0);
     assert(config->dev_mode >= 0);
-    assert(config->use_peg >= 0);
+    assert(config->_use_peg_parser >= 0);
     assert(config->install_signal_handlers >= 0);
     assert(config->use_hash_seed >= 0);
     assert(config->faulthandler >= 0);
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 6199f0c..e3fd3b2 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -185,7 +185,7 @@
     PyArena *arena;
     const char *ps1 = "", *ps2 = "", *enc = NULL;
     int errcode = 0;
-    int use_peg = _PyInterpreterState_GET()->config.use_peg;
+    int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
     _Py_IDENTIFIER(encoding);
     _Py_IDENTIFIER(__main__);
 
@@ -1030,7 +1030,7 @@
     mod_ty mod;
     PyArena *arena;
     PyObject *filename;
-    int use_peg = _PyInterpreterState_GET()->config.use_peg;
+    int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
 
     filename = _PyUnicode_FromId(&PyId_string); /* borrowed */
     if (filename == NULL)
@@ -1061,7 +1061,7 @@
     mod_ty mod;
     PyArena *arena = NULL;
     PyObject *filename;
-    int use_peg = _PyInterpreterState_GET()->config.use_peg;
+    int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
 
     filename = PyUnicode_DecodeFSDefault(filename_str);
     if (filename == NULL)
@@ -1222,7 +1222,7 @@
 {
     PyCodeObject *co;
     mod_ty mod;
-    int use_peg = _PyInterpreterState_GET()->config.use_peg;
+    int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
     PyArena *arena = PyArena_New();
     if (arena == NULL)
         return NULL;
@@ -1329,7 +1329,7 @@
 {
     struct symtable *st;
     mod_ty mod;
-    int use_peg = _PyInterpreterState_GET()->config.use_peg;
+    int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
     PyArena *arena;
 
     arena = PyArena_New();
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index cf3ddff..92ea5e7 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2427,7 +2427,6 @@
     {"inspect",                 "-i"},
     {"interactive",             "-i"},
     {"optimize",                "-O or -OO"},
-    {"use_peg",                 "-p old or -p new"},
     {"dont_write_bytecode",     "-B"},
     {"no_user_site",            "-s"},
     {"no_site",                 "-S"},
@@ -2448,7 +2447,7 @@
     "sys.flags",        /* name */
     flags__doc__,       /* doc */
     flags_fields,       /* fields */
-    16
+    15
 };
 
 static PyObject*
@@ -2471,7 +2470,6 @@
     SetFlag(config->inspect);
     SetFlag(config->interactive);
     SetFlag(config->optimization_level);
-    SetFlag(config->use_peg);
     SetFlag(!config->write_bytecode);
     SetFlag(!config->user_site_directory);
     SetFlag(!config->site_import);