Commits

Victor Stinner committed ed0e493 Draft

Move _PyUnicode_Init() to unicodeobject.c

Comments (0)

Files changed (3)

Objects/unicodenew.c

 #include "Python.h"
 #include "unicodeimpl.h"
 
-#ifdef MS_WINDOWS
-#include <windows.h>
-#endif
-
 /* --- Globals ------------------------------------------------------------
 
    The globals are initialized by the _PyUnicode_Init() API and should
     return PyUnicode_GET_LENGTH(unicode);
 }
 
-/* Initialize the Unicode implementation */
-
-int _PyUnicode_Init(void)
-{
-    int i;
-
-    /* Init the implementation */
-    _PyUnicode_Empty = PyUnicode_New(0, 0);
-    if (!_PyUnicode_Empty)
-        Py_FatalError("Can't create empty string");
-    assert(_PyUnicode_CheckConsistency(_PyUnicode_Empty, 1));
-
-    for (i = 0; i < 256; i++)
-        unicode_latin1[i] = NULL;
-    if (PyType_Ready(&PyUnicode_Type) < 0)
-        Py_FatalError("Can't initialize 'unicode'");
-
-    if (_PyUnicode_InitOperators() < 0)
-        return -1;
-    if (_PyUnicode_InitCharmap() < 0)
-        return -1;
-    if (_PyUnicode_InitOSCodecs() < 0)
-        return -1;
-    return 0;
-}
-
 /* Finalize the Unicode implementation */
 
 int
     Py_CLEAR(writer->buffer);
 }
 
+int _PyUnicode_InitNew(void)
+{
+    int i;
+    for (i = 0; i < 256; i++)
+        unicode_latin1[i] = NULL;
+    return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif

Objects/unicodeobject.c

     return PyModule_Create(&_string_module);
 }
 
+/* Initialize the Unicode implementation */
+
+int _PyUnicode_Init(void)
+{
+    /* Init the implementation */
+    _PyUnicode_Empty = PyUnicode_New(0, 0);
+    if (!_PyUnicode_Empty)
+        Py_FatalError("Can't create empty string");
+    assert(_PyUnicode_CheckConsistency(_PyUnicode_Empty, 1));
+
+    if (PyType_Ready(&PyUnicode_Type) < 0)
+        Py_FatalError("Can't initialize 'unicode'");
+
+    if (_PyUnicode_InitNew() < 0)
+        return -1;
+    if (_PyUnicode_InitOperators() < 0)
+        return -1;
+    if (_PyUnicode_InitCharmap() < 0)
+        return -1;
+    if (_PyUnicode_InitOSCodecs() < 0)
+        return -1;
+    return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif

Objects/unicodeoscodecs.c

 #include "Python.h"
 #include "unicodeimpl.h"
 
+#ifdef MS_WINDOWS
+#include <windows.h>
+#endif
+
 /* --- MBCS codecs for Windows -------------------------------------------- */
 
 #ifdef HAVE_MBCS