summaryrefslogtreecommitdiff
path: root/Programs
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-24 12:09:24 +0100
committerGitHub <noreply@github.com>2017-11-24 12:09:24 +0100
commit9e87e7776f7ace66baaf7247233afdabd00c2b44 (patch)
treee43699904e2de8394d7e408b231174f7a87c9b4a /Programs
parent4864a619dc1cc9092780ccf5a6327e8abf66133d (diff)
downloadcpython-git-9e87e7776f7ace66baaf7247233afdabd00c2b44.tar.gz
bpo-32096: Remove obj and mem from _PyRuntime (#4532)
bpo-32096, bpo-30860: Partially revert the commit 2ebc5ce42a8a9e047e790aefbf9a94811569b2b6: * Move structures back from Include/internal/mem.h to Objects/obmalloc.c * Remove _PyObject_Initialize() and _PyMem_Initialize() * Remove Include/internal/pymalloc.h * Add test_capi.test_pre_initialization_api(): Make sure that it's possible to call Py_DecodeLocale(), and then call Py_SetProgramName() with the decoded string, before Py_Initialize(). PyMem_RawMalloc() and Py_DecodeLocale() can be called again before _PyRuntimeState_Init(). Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_testembed.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index e68e68de32..52a0b5124a 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -125,6 +125,28 @@ static int test_forced_io_encoding(void)
return 0;
}
+
+/*********************************************************
+ * Test parts of the C-API that work before initialization
+ *********************************************************/
+
+static int test_pre_initialization_api(void)
+{
+ wchar_t *program = Py_DecodeLocale("spam", NULL);
+ if (program == NULL) {
+ fprintf(stderr, "Fatal error: cannot decode program name\n");
+ return 1;
+ }
+ Py_SetProgramName(program);
+
+ Py_Initialize();
+ Py_Finalize();
+
+ PyMem_RawFree(program);
+ return 0;
+}
+
+
/* *********************************************************
* List of test cases and the function that implements it.
*
@@ -146,6 +168,7 @@ struct TestCase
static struct TestCase TestCases[] = {
{ "forced_io_encoding", test_forced_io_encoding },
{ "repeated_init_and_subinterpreters", test_repeated_init_and_subinterpreters },
+ { "pre_initialization_api", test_pre_initialization_api },
{ NULL, NULL }
};