Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f95dd0a

Browse files
committed
Fix portability problems with glibc 2.0, as reported in #449157.
1 parent 834a85a commit f95dd0a

7 files changed

Lines changed: 23 additions & 4 deletions

File tree

Modules/_localemodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ init_locale(void)
527527
ADDINT(ABMON_11);
528528
ADDINT(ABMON_12);
529529

530+
#ifdef RADIXCHAR
531+
/* The following are not available with glibc 2.0 */
530532
ADDINT(RADIXCHAR);
531533
ADDINT(THOUSEP);
532534
/* YESSTR and NOSTR are deprecated in glibc, since they are
@@ -537,6 +539,7 @@ init_locale(void)
537539
ADDINT(NOSTR);
538540
*/
539541
ADDINT(CRNCYSTR);
542+
#endif
540543

541544
ADDINT(D_T_FMT);
542545
ADDINT(D_FMT);

Modules/addrinfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
6868
#endif
6969

70+
#endif /* HAVE_GETADDRINFO */
71+
72+
#ifndef HAVE_GETNAMEINFO
73+
7074
/*
7175
* Constants for getnameinfo()
7276
*/
@@ -86,6 +90,8 @@
8690
#define NI_DGRAM 0x00000010
8791
#endif
8892

93+
#endif /* HAVE_GETNAMEINFO */
94+
8995
#ifndef HAVE_ADDRINFO
9096
struct addrinfo {
9197
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
@@ -137,4 +143,3 @@ extern void freehostent Py_PROTO((struct hostent *));
137143
#ifdef __cplusplus
138144
}
139145
#endif
140-
#endif

Modules/getnameinfo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ struct gni_sockinet {
8181
#define ENI_FAMILY 5
8282
#define ENI_SALEN 6
8383

84+
/* forward declaration to make gcc happy */
85+
int getnameinfo Py_PROTO((const struct sockaddr *, size_t, char *, size_t,
86+
char *, size_t, int));
87+
8488
int
8589
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
8690
const struct sockaddr *sa;

Modules/socketmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,11 @@ PyGAI_Err(int error)
447447
if (error == EAI_SYSTEM)
448448
return PySocket_Err();
449449

450+
#ifdef HAVE_GAI_STRERROR
450451
v = Py_BuildValue("(is)", error, gai_strerror(error));
452+
#else
453+
v = Py_BuildValue("(is)", error, "getaddrinfo failed");
454+
#endif
451455
if (v != NULL) {
452456
PyErr_SetObject(PyGAI_Error, v);
453457
Py_DECREF(v);

configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22

3-
# From configure.in Revision: 1.245
3+
# From configure.in Revision: 1.246
44

55
# Guess values for system-dependent variables and create Makefiles.
66
# Generated automatically using autoconf version 2.13
@@ -4570,7 +4570,7 @@ echo "$ac_t""MACHDEP_OBJS" 1>&6
45704570
# checks for library functions
45714571
for ac_func in alarm chown clock confstr ctermid ctermid_r execv \
45724572
flock fork fsync fdatasync fpathconf ftime ftruncate \
4573-
getgroups getlogin getpeername getpid getpwent getwd \
4573+
gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
45744574
hstrerror inet_pton kill link lstat mkfifo mktime mremap \
45754575
nice pathconf pause plock poll pthread_init \
45764576
putenv readlink \

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ AC_MSG_RESULT(MACHDEP_OBJS)
12361236
# checks for library functions
12371237
AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
12381238
flock fork fsync fdatasync fpathconf ftime ftruncate \
1239-
getgroups getlogin getpeername getpid getpwent getwd \
1239+
gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
12401240
hstrerror inet_pton kill link lstat mkfifo mktime mremap \
12411241
nice pathconf pause plock poll pthread_init \
12421242
putenv readlink \

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@
371371
/* Define if you have the ftruncate function. */
372372
#undef HAVE_FTRUNCATE
373373

374+
/* Define if you have the gai_strerror function. */
375+
#undef HAVE_GAI_STRERROR
376+
374377
/* Define if you have the getaddrinfo function. */
375378
#undef HAVE_GETADDRINFO
376379

0 commit comments

Comments
 (0)