ladybird/Ports/python-3.6/patches/0003-Remove-locale-setup-and-use-utf-8-as-default.patch
Emanuel Sprung 71823a6c49 Ports: Add initial Python 3.6 port
This port is experimental and not all pythom modules are working.
But this is an initial shot which can be further worked on, as
SerenityOS gets more mature. :^)

The main limitation is that locales, threading and time related
functions are not working.
2019-11-11 22:04:16 +01:00

82 lines
2.5 KiB
Diff

diff --git a/Modules/main.c b/Modules/main.c
index d75f64a..143a452 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -557,8 +557,8 @@ Py_Main(int argc, wchar_t **argv)
Py_FatalError(
"not enough memory to copy PYTHONWARNINGS");
strcpy(buf, p);
- oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
- setlocale(LC_ALL, "");
+ //oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
+ //setlocale(LC_ALL, "");
for (p = strtok(buf, ","); p != NULL; p = strtok(NULL, ",")) {
#ifdef __APPLE__
/* Use utf-8 on Mac OS X */
@@ -574,8 +574,8 @@ Py_Main(int argc, wchar_t **argv)
PySys_AddWarnOptionUnicode(unicode);
Py_DECREF(unicode);
}
- setlocale(LC_ALL, oldloc);
- PyMem_RawFree(oldloc);
+ //setlocale(LC_ALL, oldloc);
+ //PyMem_RawFree(oldloc);
PyMem_RawFree(buf);
}
#endif
diff --git a/Programs/python.c b/Programs/python.c
index a7afbc7..07fcbe0 100644
--- a/Programs/python.c
+++ b/Programs/python.c
@@ -43,17 +43,17 @@ main(int argc, char **argv)
fedisableexcept(FE_OVERFLOW);
#endif
- oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
- if (!oldloc) {
- fprintf(stderr, "out of memory\n");
- return 1;
- }
+ // oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
+ // if (!oldloc) {
+ // fprintf(stderr, "out of memory\n");
+ // return 1;
+ // }
- setlocale(LC_ALL, "");
+ // setlocale(LC_ALL, "");
for (i = 0; i < argc; i++) {
argv_copy[i] = Py_DecodeLocale(argv[i], NULL);
if (!argv_copy[i]) {
- PyMem_RawFree(oldloc);
+ //PyMem_RawFree(oldloc);
fprintf(stderr, "Fatal Python error: "
"unable to decode the command line argument #%i\n",
i + 1);
@@ -63,8 +63,8 @@ main(int argc, char **argv)
}
argv_copy2[argc] = argv_copy[argc] = NULL;
- setlocale(LC_ALL, oldloc);
- PyMem_RawFree(oldloc);
+ //setlocale(LC_ALL, oldloc);
+ //PyMem_RawFree(oldloc);
res = Py_Main(argc, argv_copy);
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index a4f7f82..823372f 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -238,6 +238,8 @@ get_locale_encoding(void)
return get_codec_name(codeset);
#elif defined(__ANDROID__)
return get_codec_name("UTF-8");
+#elif defined(__serenity__)
+ return get_codec_name("UTF-8");
#else
PyErr_SetNone(PyExc_NotImplementedError);
return NULL;
--
2.17.1