diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-04-18 09:37:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-18 09:37:26 (GMT) |
commit | 23bace26ec265557697cf3b578b361c178070cd5 (patch) | |
tree | 41d99b73d99a1f8295ed6177113ed7796c8ed784 /Programs | |
parent | 11efd79076559cc6e4034bb36db73e5e4293f02d (diff) | |
download | cpython-23bace26ec265557697cf3b578b361c178070cd5.zip cpython-23bace26ec265557697cf3b578b361c178070cd5.tar.gz cpython-23bace26ec265557697cf3b578b361c178070cd5.tar.bz2 |
bpo-36635: Add _testinternalcapi module (GH-12841)
Add a new _testinternalcapi module to test the internal C API.
Move _Py_GetConfigsAsDict() function to the internal C API:
_testembed now uses _testinternalcapi to access the function.
Diffstat (limited to 'Programs')
-rw-r--r-- | Programs/_testembed.c | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index 7d71a96..3fc8e6d 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -298,42 +298,13 @@ static int test_initialize_pymain(void) } -static int -dump_config_impl(void) -{ - PyObject *config = _Py_GetConfigsAsDict(); - if (config == NULL) { - return -1; - } - - PyObject *res; - PyObject *json = PyImport_ImportModule("json"); - if (json) { - res = PyObject_CallMethod(json, "dumps", "O", config); - Py_DECREF(json); - } - else { - res = NULL; - } - Py_CLEAR(config); - if (res == NULL) { - return -1; - } - - PySys_FormatStdout("%S\n", res); - Py_DECREF(res); - - return 0; -} - - static void dump_config(void) { - if (dump_config_impl() < 0) { - fprintf(stderr, "failed to dump the configuration:\n"); - PyErr_Print(); - } + (void) PyRun_SimpleStringFlags( + "import _testinternalcapi, json; " + "print(json.dumps(_testinternalcapi.get_configs()))", + 0); } |