X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/_bootlocale.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def getpreferredencoding(do_setlocale=True):
return _locale._getdefaultlocale()[1]
else:
try:
_locale.CODESET
_locale.nl_langinfo, _locale.CODESET
except AttributeError:
if hasattr(sys, 'getandroidapilevel'):
# On Android langinfo.h and CODESET are missing, and UTF-8 is
# On Android nl_langinfo() is missing, and UTF-8 is
# always used in mbstowcs() and wcstombs().
def getpreferredencoding(do_setlocale=True):
return 'UTF-8'
Expand Down
6 changes: 3 additions & 3 deletions Lib/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,12 +614,12 @@ def getpreferredencoding(do_setlocale = True):
import _bootlocale
return _bootlocale.getpreferredencoding(False)
else:
# On Unix, if CODESET is available, use that.
# On Unix, if both nl_langinfo and CODESET are available, use them.
try:
CODESET
nl_langinfo, CODESET
except NameError:
if hasattr(sys, 'getandroidapilevel'):
# On Android langinfo.h and CODESET are missing, and UTF-8 is
# On Android nl_langinfo() is missing, and UTF-8 is
# always used in mbstowcs() and wcstombs().
def getpreferredencoding(do_setlocale = True):
return 'UTF-8'
Expand Down
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@ Documentation
Build
-----

- bpo-29436: fix compilation failure on Android since NDK r14 beta 2

- Issue #27659: Prohibit implicit C function declarations: use
-Werror=implicit-function-declaration when possible (GCC and Clang, but it
depends on the compiler version). Patch written by Chi Hsuan Yen.
Expand Down
2 changes: 1 addition & 1 deletion Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ PyCursesWindow_New(WINDOW *win, const char *encoding)
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;
Expand Down
4 changes: 3 additions & 1 deletion Modules/_localemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ static struct langinfo_constant{
{0, 0}
};

#ifdef HAVE_NL_LANGINFO
PyDoc_STRVAR(nl_langinfo__doc__,
"nl_langinfo(key) -> string\n"
"Return the value for the locale information associated with key.");
Expand All @@ -451,6 +452,7 @@ PyLocale_nl_langinfo(PyObject* self, PyObject* args)
PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant");
return NULL;
}
#endif /* HAVE_NL_LANGINFO */
#endif /* HAVE_LANGINFO_H */

#ifdef HAVE_LIBINTL_H
Expand Down Expand Up @@ -583,7 +585,7 @@ static struct PyMethodDef PyLocale_Methods[] = {
#if defined(MS_WINDOWS)
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS},
#endif
#ifdef HAVE_LANGINFO_H
#if defined(HAVE_NL_LANGINFO)
{"nl_langinfo", (PyCFunction) PyLocale_nl_langinfo,
METH_VARARGS, nl_langinfo__doc__},
#endif
Expand Down
6 changes: 3 additions & 3 deletions Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ _Py_device_encoding(int fd)
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)
Expand Down Expand Up @@ -102,7 +102,7 @@ static int
check_force_ascii(void)
{
char *loc;
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
char *codeset, **alias;
char encoding[20]; /* longest name: "iso_646.irv_1991\0" */
int is_ascii;
Expand Down Expand Up @@ -134,7 +134,7 @@ check_force_ascii(void)
return 0;
}

#if defined(HAVE_LANGINFO_H) && defined(CODESET)
#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
codeset = nl_langinfo(CODESET);
if (!codeset || codeset[0] == '\0') {
/* CODESET is not set or empty */
Expand Down
2 changes: 1 addition & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ get_locale_encoding(void)
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_NL_LANGINFO) && defined(CODESET)
char* codeset = nl_langinfo(CODESET);
if (!codeset || codeset[0] == '\0') {
PyErr_SetString(PyExc_ValueError, "CODESET is not set or empty");
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -11261,7 +11261,7 @@ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
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 \
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3422,7 +3422,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
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 \
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@
/* Define to 1 if you have the `nice' function. */
#undef HAVE_NICE

/* Define to 1 if you have the `nl_langinfo' function. */
#undef HAVE_NL_LANGINFO

/* Define to 1 if you have the `openat' function. */
#undef HAVE_OPENAT

Expand Down
X Tutup