Simplify os_init() implementations by using PyErr_Format()

directly instead of PyOS_snprintf()+PyErr_SetString().
This commit is contained in:
Walter Dörwald 2007-06-05 13:49:43 +00:00
parent 9cb0802cb5
commit 0bbd8abe6b
1 changed files with 2 additions and 8 deletions

View File

@ -4045,7 +4045,6 @@ os_init(void)
{ {
WSADATA WSAData; WSADATA WSAData;
int ret; int ret;
char buf[100];
ret = WSAStartup(0x0101, &WSAData); ret = WSAStartup(0x0101, &WSAData);
switch (ret) { switch (ret) {
case 0: /* No error */ case 0: /* No error */
@ -4062,9 +4061,7 @@ os_init(void)
"WSAStartup failed: requested version not supported"); "WSAStartup failed: requested version not supported");
break; break;
default: default:
PyOS_snprintf(buf, sizeof(buf), PyErr_Format(PyExc_ImportError, "WSAStartup failed: error code %d", ret);
"WSAStartup failed: error code %d", ret);
PyErr_SetString(PyExc_ImportError, buf);
break; break;
} }
return 0; /* Failure */ return 0; /* Failure */
@ -4082,16 +4079,13 @@ static int
os_init(void) os_init(void)
{ {
#ifndef PYCC_GCC #ifndef PYCC_GCC
char reason[64];
int rc = sock_init(); int rc = sock_init();
if (rc == 0) { if (rc == 0) {
return 1; /* Success */ return 1; /* Success */
} }
PyOS_snprintf(reason, sizeof(reason), PyErr_Format(PyExc_ImportError, "OS/2 TCP/IP Error# %d", sock_errno());
"OS/2 TCP/IP Error# %d", sock_errno());
PyErr_SetString(PyExc_ImportError, reason);
return 0; /* Failure */ return 0; /* Failure */
#else #else