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

Skip to content

Commit 864e9ff

Browse files
committed
Auto-detect hstrerror. Raise socket.herror in PyH_Error. Register the three
exception classes in the module dictionary.
1 parent c9908c4 commit 864e9ff

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

Modules/socketmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ PyH_Err(int h_error)
431431
v = Py_BuildValue("(is)", h_error, "host not found");
432432
#endif
433433
if (v != NULL) {
434-
PyErr_SetObject(PyGAI_Error, v);
434+
PyErr_SetObject(PyH_Error, v);
435435
Py_DECREF(v);
436436
}
437437

@@ -2915,13 +2915,16 @@ init_socket(void)
29152915
PySocket_Error = PyErr_NewException("socket.error", NULL, NULL);
29162916
if (PySocket_Error == NULL)
29172917
return;
2918+
PyDict_SetItemString(d, "error", PySocket_Error);
29182919
PyH_Error = PyErr_NewException("socket.herror", PySocket_Error, NULL);
29192920
if (PyH_Error == NULL)
29202921
return;
2922+
PyDict_SetItemString(d, "herror", PyH_Error);
29212923
PyGAI_Error = PyErr_NewException("socket.gaierror", PySocket_Error,
29222924
NULL);
29232925
if (PyGAI_Error == NULL)
29242926
return;
2927+
PyDict_SetItemString(d, "gaierror", PyGAI_Error);
29252928
#ifdef USE_SSL
29262929
SSL_load_error_strings();
29272930
SSLeay_add_ssl_algorithms();
@@ -2934,7 +2937,6 @@ init_socket(void)
29342937
(PyObject *)&SSL_Type) != 0)
29352938
return;
29362939
#endif /* USE_SSL */
2937-
PyDict_SetItemString(d, "error", PySocket_Error);
29382940
PySocketSock_Type.ob_type = &PyType_Type;
29392941
PySocketSock_Type.tp_doc = sockettype_doc;
29402942
Py_INCREF(&PySocketSock_Type);

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.236
3+
# From configure.in Revision: 1.237
44

55
# Guess values for system-dependent variables and create Makefiles.
66
# Generated automatically using autoconf version 2.13
@@ -4518,7 +4518,7 @@ echo "$ac_t""$DYNLOADFILE" 1>&6
45184518
for ac_func in alarm chown clock confstr ctermid ctermid_r execv \
45194519
flock fork fsync fdatasync fpathconf ftime ftruncate \
45204520
getgroups getlogin getpeername getpid getpwent getwd \
4521-
inet_pton kill link lstat mkfifo mktime mremap \
4521+
hstrerror inet_pton kill link lstat mkfifo mktime mremap \
45224522
nice pathconf pause plock poll pthread_init \
45234523
putenv readlink \
45244524
select setegid seteuid setgid \

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ AC_MSG_RESULT($DYNLOADFILE)
11781178
AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
11791179
flock fork fsync fdatasync fpathconf ftime ftruncate \
11801180
getgroups getlogin getpeername getpid getpwent getwd \
1181-
inet_pton kill link lstat mkfifo mktime mremap \
1181+
hstrerror inet_pton kill link lstat mkfifo mktime mremap \
11821182
nice pathconf pause plock poll pthread_init \
11831183
putenv readlink \
11841184
select setegid seteuid setgid \

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@
410410
/* Define if you have the getwd function. */
411411
#undef HAVE_GETWD
412412

413+
/* Define if you have the hstrerror function. */
414+
#undef HAVE_HSTRERROR
415+
413416
/* Define if you have the hypot function. */
414417
#undef HAVE_HYPOT
415418

0 commit comments

Comments
 (0)