summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-23 01:03:24 (GMT)
committerGitHub <noreply@github.com>2020-04-23 01:03:24 (GMT)
commit1def7754b7a41fe57efafaf5eff24cfa15353444 (patch)
tree8fd9f9ddeaf9a66f92d1916b86901573afce0ccb /Python
parenta25f3c4c8f7d4878918ce1d3d67db40ae255ccc6 (diff)
downloadcpython-1def7754b7a41fe57efafaf5eff24cfa15353444.zip
cpython-1def7754b7a41fe57efafaf5eff24cfa15353444.tar.gz
cpython-1def7754b7a41fe57efafaf5eff24cfa15353444.tar.bz2
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
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c6
-rw-r--r--Python/initconfig.c10
-rw-r--r--Python/pythonrun.c10
-rw-r--r--Python/sysmodule.c4
4 files changed, 14 insertions, 16 deletions
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 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
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 @@ _PyConfig_InitCompatConfig(PyConfig *config)
#ifdef MS_WINDOWS
config->legacy_windows_stdio = -1;
#endif
- config->use_peg = 1;
+ config->_use_peg_parser = 1;
}
@@ -793,7 +793,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
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 @@ config_as_dict(const PyConfig *config)
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 @@ config_read_complex_options(PyConfig *config)
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 @@ PyConfig_Read(PyConfig *config)
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 @@ PyRun_InteractiveOneObjectEx(FILE *fp, PyObject *filename,
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 @@ PyRun_StringFlags(const char *str, int start, PyObject *globals,
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 @@ PyRun_FileExFlags(FILE *fp, const char *filename_str, int start, PyObject *globa
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 @@ Py_CompileStringObject(const char *str, PyObject *filename, int start,
{
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 @@ _Py_SymtableStringObjectFlags(const char *str, PyObject *filename, int start, Py
{
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 @@ static PyStructSequence_Field flags_fields[] = {
{"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 @@ static PyStructSequence_Desc flags_desc = {
"sys.flags", /* name */
flags__doc__, /* doc */
flags_fields, /* fields */
- 16
+ 15
};
static PyObject*
@@ -2471,7 +2470,6 @@ make_flags(PyThreadState *tstate)
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);