diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -225,17 +225,17 @@ error: static char* get_locale_encoding(void) { #ifdef MS_WINDOWS char codepage[100]; PyOS_snprintf(codepage, sizeof(codepage), "cp%d", GetACP()); return get_codec_name(codepage); -#elif defined(HAVE_LANGINFO_H) && defined(CODESET) +#elif defined(HAVE_LANGINFO_H) && defined(HAVE_NL_LANGINFO) && defined(CODESET) char* codeset = nl_langinfo(CODESET); if (!codeset || codeset[0] == '\0') { PyErr_SetString(PyExc_ValueError, "CODESET is not set or empty"); return NULL; } return get_codec_name(codeset); #elif defined(__ANDROID__) return get_codec_name("UTF-8"); diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -3397,17 +3397,17 @@ fi AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ clock confstr ctermid dup3 execv faccessat fchmod fchmodat fchown fchownat \ fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \ futimens futimes gai_strerror getentropy \ getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ initgroups kill killpg lchmod lchown linkat lstat lutimes mmap \ memrchr mbrtowc mkdirat mkfifo \ - mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \ + mkfifoat mknod mknodat mktime mremap nice nl_langinfo openat pathconf pause pipe2 plock poll \ posix_fallocate posix_fadvise pread \ pthread_init pthread_kill putenv pwrite readlink readlinkat readv realpath renameat \ select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \ setgid sethostname \ setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \ sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \ sched_rr_get_interval \ sigaction sigaltstack siginterrupt sigpending sigrelse \ diff --git a/Python/fileutils.c b/Python/fileutils.c --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -55,17 +55,17 @@ PyObject * else if (fd == 1 || fd == 2) cp = GetConsoleOutputCP(); else cp = 0; /* GetConsoleCP() and GetConsoleOutputCP() return 0 if the application has no console */ if (cp != 0) return PyUnicode_FromFormat("cp%u", (unsigned int)cp); -#elif defined(CODESET) +#elif defined(HAVE_NL_LANGINFO) && defined(CODESET) { char *codeset = nl_langinfo(CODESET); if (codeset != NULL && codeset[0] != 0) return PyUnicode_FromString(codeset); } #endif Py_RETURN_NONE; } @@ -129,17 +129,17 @@ check_force_ascii(void) loc = setlocale(LC_CTYPE, NULL); if (loc == NULL) goto error; if (strcmp(loc, "C") != 0) { /* the LC_CTYPE locale is different than C */ return 0; } -#if defined(HAVE_LANGINFO_H) && defined(CODESET) +#if defined(HAVE_LANGINFO_H) && defined(HAVE_NL_LANGINFO) && defined(CODESET) codeset = nl_langinfo(CODESET); if (!codeset || codeset[0] == '\0') { /* CODESET is not set or empty */ goto error; } if (!_Py_normalize_encoding(codeset, encoding, sizeof(encoding))) goto error; diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -313,17 +313,17 @@ PyLocale_getdefaultlocale(PyObject* self } /* cannot determine the language code (very unlikely) */ Py_INCREF(Py_None); return Py_BuildValue("Os", Py_None, encoding); } #endif -#ifdef HAVE_LANGINFO_H +#if defined(HAVE_LANGINFO_H) && defined(HAVE_NL_LANGINFO) #define LANGINFO(X) {#X, X} static struct langinfo_constant{ char* name; int value; } langinfo_constants[] = { /* These constants should exist on any langinfo implementation */ LANGINFO(DAY_1), @@ -446,17 +446,17 @@ PyLocale_nl_langinfo(PyObject* self, PyO instead of an empty string for nl_langinfo(ERA). */ const char *result = nl_langinfo(item); result = result != NULL ? result : ""; return PyUnicode_DecodeLocale(result, NULL); } PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant"); return NULL; } -#endif /* HAVE_LANGINFO_H */ +#endif /* defined(HAVE_LANGINFO_H) && defined(HAVE_NL_LANGINFO) */ #ifdef HAVE_LIBINTL_H PyDoc_STRVAR(gettext__doc__, "gettext(msg) -> string\n" "Return translation of msg."); static PyObject* @@ -578,17 +578,17 @@ static struct PyMethodDef PyLocale_Metho #endif #ifdef HAVE_WCSXFRM {"strxfrm", (PyCFunction) PyLocale_strxfrm, METH_VARARGS, strxfrm__doc__}, #endif #if defined(MS_WINDOWS) {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS}, #endif -#ifdef HAVE_LANGINFO_H +#if defined(HAVE_LANGINFO_H) && defined(HAVE_NL_LANGINFO) {"nl_langinfo", (PyCFunction) PyLocale_nl_langinfo, METH_VARARGS, nl_langinfo__doc__}, #endif #ifdef HAVE_LIBINTL_H {"gettext",(PyCFunction)PyIntl_gettext,METH_VARARGS, gettext__doc__}, {"dgettext",(PyCFunction)PyIntl_dgettext,METH_VARARGS, dgettext__doc__}, @@ -618,17 +618,17 @@ static struct PyModuleDef _localemodule NULL, NULL }; PyMODINIT_FUNC PyInit__locale(void) { PyObject *m; -#ifdef HAVE_LANGINFO_H +#if defined(HAVE_LANGINFO_H) && defined(HAVE_NL_LANGINFO) int i; #endif m = PyModule_Create(&_localemodule); if (m == NULL) return NULL; PyModule_AddIntMacro(m, LC_CTYPE); @@ -646,17 +646,17 @@ PyInit__locale(void) Error = PyErr_NewException("locale.Error", NULL, NULL); if (Error == NULL) { Py_DECREF(m); return NULL; } PyModule_AddObject(m, "Error", Error); -#ifdef HAVE_LANGINFO_H +#if defined(HAVE_LANGINFO_H) && defined(HAVE_NL_LANGINFO) for (i = 0; langinfo_constants[i].name; i++) { PyModule_AddIntConstant(m, langinfo_constants[i].name, langinfo_constants[i].value); } #endif if (PyErr_Occurred()) { Py_DECREF(m); diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -518,17 +518,17 @@ PyCursesWindow_New(WINDOW *win, const ch #if defined(MS_WINDOWS) char *buffer[100]; UINT cp; cp = GetConsoleOutputCP(); if (cp != 0) { PyOS_snprintf(buffer, sizeof(buffer), "cp%u", cp); encoding = buffer; } -#elif defined(CODESET) +#elif defined(HAVE_NL_LANGINFO) && defined(CODESET) const char *codeset = nl_langinfo(CODESET); if (codeset != NULL && codeset[0] != 0) encoding = codeset; #endif if (encoding == NULL) encoding = "utf-8"; }