Commit e4485b06 authored by Guido van Rossum's avatar Guido van Rossum

Setup.in: added tkinter; rearranged the definition of PYTHONPATH so

that the module-specific components are in the section for that
module.

cursesmodule.c: patched it so it actually works.

tkintermodule.c: call Py_AtExit instead of atexit().

signalmodule.c: converted to new naming style; added
BGN/END SAVE around pause() call.

socketmodule.c: added setblocking() after Tommy Burnette.
parent a1426136
...@@ -53,10 +53,7 @@ TESTPATH=:$(DESTLIB)/test ...@@ -53,10 +53,7 @@ TESTPATH=:$(DESTLIB)/test
# Enable this for Sun systems # Enable this for Sun systems
#ARCHPATH=:$(DESTLIB)/sun4 #ARCHPATH=:$(DESTLIB)/sun4
# Enable this if stdwin installed PYTHONPATH=.:$(DESTLIB)$(TESTPATH)$(ARCHPATH)$(STDWINPATH)$(TKPATH)
#STDWINPATH=:$(DESTLIB)/stdwin
PYTHONPATH=.:$(DESTLIB)$(TESTPATH)$(ARCHPATH)$(STDWINPATH)
# Modules that should always be present (non UNIX dependent) # Modules that should always be present (non UNIX dependent)
...@@ -104,12 +101,13 @@ rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably) ...@@ -104,12 +101,13 @@ rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably)
# ftp://ftp.cwi.nl/pub/stdwin. The STDWIN variable must point to the # ftp://ftp.cwi.nl/pub/stdwin. The STDWIN variable must point to the
# STDWIN toplevel directory. The ARCH variable must be set to the # STDWIN toplevel directory. The ARCH variable must be set to the
# architecture identifier used to build STDWIN. NB if you combine this # architecture identifier used to build STDWIN. NB if you combine this
# with the gl module on an SGI machine, you should replace "-lX11" with # with the gl module on an SGI IRIX 4 machine, you should replace
# "-lX11_s". "-lX11" with "-lX11_s".
#STDWIN=/ufs/guido/src/stdwin #STDWIN=/ufs/guido/src/stdwin
#ARCH=??? #ARCH=???
#stdwin stdwinmodule.c -I$(STDWIN)/H $(STDWIN)/Build/$(ARCH)/x11/lib/lib.a -lX11 #stdwin stdwinmodule.c -I$(STDWIN)/H $(STDWIN)/Build/$(ARCH)/x11/lib/lib.a -lX11
#STDWINPATH=:$(DESTLIB)/stdwin
# The md5 module implements the RSA Data Security, Inc. MD5 # The md5 module implements the RSA Data Security, Inc. MD5
...@@ -174,8 +172,18 @@ md5 md5module.c md5c.c ...@@ -174,8 +172,18 @@ md5 md5module.c md5c.c
# timing timingmodule.c # timing timingmodule.c
# Steen Lumholt's tkinter module. For use with plain Tk, use the
# first line. For use with extended Tk, edit tkappinit.c, add
# appropriate -DWITH_... and libraries/objects to the second line, and
# use that. In all cases also enable the last line (TKPATH).
#tkinter tkintermodule.c -I/usr/local/include -L/usr/local/lib -ltk -ltcl -lX11
#tkinter tkintermodule.c tkappinit.c -DWITH_APPINIT -I/usr/local/include -L/usr/local/lib -ltk -ltcl -lX11
#TKPATH=:$(DESTLIB)/tkinter
# Lance Ellinghouse's modules # Lance Ellinghouse's modules
rotor rotormodule.c # enigma-inspired en-, decryption rotor rotormodule.c # enigma-inspired encryption
# syslog syslogmodule.c # syslog daemon interface # syslog syslogmodule.c # syslog daemon interface
# curses cursesmodule.c -lcurses -ltermcap # guess what? # curses cursesmodule.c -lcurses -ltermcap # guess what?
......
...@@ -1033,6 +1033,8 @@ static PyTypeObject PyCursesPad_Type = { ...@@ -1033,6 +1033,8 @@ static PyTypeObject PyCursesPad_Type = {
/* -------------------------------------------------------*/ /* -------------------------------------------------------*/
static PyObject *ModDict;
static PyObject * static PyObject *
PyCurses_InitScr(self, args) PyCurses_InitScr(self, args)
PyObject * self; PyObject * self;
...@@ -1052,7 +1054,7 @@ PyCurses_InitScr(self, args) ...@@ -1052,7 +1054,7 @@ PyCurses_InitScr(self, args)
/* This was moved from initcurses() because core dumped on SGI */ /* This was moved from initcurses() because core dumped on SGI */
#define SetDictChar(string,ch) \ #define SetDictChar(string,ch) \
PyDict_SetItemString(d,string,PyInt_FromLong(ch)); PyDict_SetItemString(ModDict,string,PyInt_FromLong(ch));
/* Here are some graphic symbols you can use */ /* Here are some graphic symbols you can use */
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER)); SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
...@@ -1387,6 +1389,7 @@ initcurses() ...@@ -1387,6 +1389,7 @@ initcurses()
Py_INCREF(PyCurses_ERR); Py_INCREF(PyCurses_ERR);
/* Add some symbolic constants to the module */ /* Add some symbolic constants to the module */
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
ModDict = d; /* For PyCurses_InitScr */
/* Make the version available */ /* Make the version available */
PyDict_SetItemString(d,"version", PyDict_SetItemString(d,"version",
......
...@@ -1092,8 +1092,9 @@ PyInit_tkinter () ...@@ -1092,8 +1092,9 @@ PyInit_tkinter ()
if (!inited) if (!inited)
{ {
inited = 1; inited = 1;
if (atexit (Tkinter_Cleanup)) if (Py_AtExit (Tkinter_Cleanup) != 0)
PyErr_SetFromErrno (Tkinter_TclError); fprintf(stderr,
"Tkinter: warning: cleanup procedure not registered\n");
} }
if (PyErr_Occurred ()) if (PyErr_Occurred ())
......
...@@ -32,6 +32,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -32,6 +32,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include "rename1.h"
#ifndef SIG_ERR #ifndef SIG_ERR
#define SIG_ERR ((RETSIGTYPE (*)())-1) #define SIG_ERR ((RETSIGTYPE (*)())-1)
#endif #endif
...@@ -68,147 +70,150 @@ static long main_thread; ...@@ -68,147 +70,150 @@ static long main_thread;
static pid_t main_pid; static pid_t main_pid;
#endif #endif
struct signalhandler_list { struct PySignal_SignalArrayStruct {
int tripped; int tripped;
object *func; PyObject *func;
}; };
static struct signalhandler_list sig_list[NSIG]; static struct PySignal_SignalArrayStruct PySignal_SignalHandlerArray[NSIG];
static int tripped = 0; /* Speed up sigcheck() when none tripped */ static int PySignal_IsTripped = 0; /* Speed up sigcheck() when none tripped */
static object *sig_dfl_object; static PyObject *PySignal_SignalDefaultHandler;
static object *sig_ign_object; static PyObject *PySignal_SignalIgnoreHandler;
static object *default_int_handler_object; static PyObject *PySignal_DefaultIntHandler;
static object * static PyObject *
default_int_handler(self, arg) PySignal_CDefaultIntHandler(self, arg)
object *self; PyObject *self;
object *arg; PyObject *arg;
{ {
err_set(KeyboardInterrupt); PyErr_SetNone(PyExc_KeyboardInterrupt);
return NULL; return (PyObject *)NULL;
} }
static RETSIGTYPE static RETSIGTYPE
signal_handler(sig_num) PySignal_Handler(sig_num)
int sig_num; int sig_num;
{ {
#ifdef WITH_THREAD #ifdef WITH_THREAD
/* See NOTES section above */ /* See NOTES section above */
if (getpid() == main_pid) { if (getpid() == main_pid) {
#endif #endif
tripped++; PySignal_IsTripped++;
sig_list[sig_num].tripped = 1; PySignal_SignalHandlerArray[sig_num].tripped = 1;
#ifdef WITH_THREAD #ifdef WITH_THREAD
} }
#endif #endif
(void *)signal(sig_num, &signal_handler); (void *)signal(sig_num, &PySignal_Handler);
} }
static object *
signal_alarm(self, args) static PyObject *
object *self; /* Not used */ PySignal_Alarm(self, args)
object *args; PyObject *self; /* Not used */
PyObject *args;
{ {
int t; int t;
if (!getargs(args, "i", &t)) int rtn;
return NULL; if (!PyArg_Parse(args, "i", &t))
alarm(t); return (PyObject *)NULL;
INCREF(None); /* alarm() returns the number of seconds remaining */
return None; return PyInt_FromLong(alarm(t));
} }
static object * static object *
signal_pause(self, args) PySignal_Pause(self, args)
object *self; /* Not used */ PyObject *self; /* Not used */
object *args; PyObject *args;
{ {
if (!getnoarg(args)) if (!PyArg_NoArgs(args))
return NULL; return NULL;
BGN_SAVE
pause(); pause();
INCREF(None); END_SAVE
return None; Py_INCREF(Py_None);
return Py_None;
} }
static object * static PyObject *
signal_signal(self, args) PySignal_Signal(self, args)
object *self; /* Not used */ PyObject *self; /* Not used */
object *args; PyObject *args;
{ {
object *obj; PyObject *obj;
int sig_num; int sig_num;
object *old_handler; PyObject *old_handler;
RETSIGTYPE (*func)(); RETSIGTYPE (*func)();
if (!getargs(args, "(iO)", &sig_num, &obj)) if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
return NULL; return (PyObject *)NULL;
#ifdef WITH_THREAD #ifdef WITH_THREAD
if (get_thread_ident() != main_thread) { if (get_thread_ident() != main_thread) {
err_setstr(ValueError, "signal only works in main thread"); PyErr_SetString(PyExc_ValueError, "signal only works in main thread");
return NULL; return (PyObject *)NULL;
} }
#endif #endif
if (sig_num < 1 || sig_num >= NSIG) { if (sig_num < 1 || sig_num >= NSIG) {
err_setstr(ValueError, "signal number out of range"); PyErr_SetString(PyExc_ValueError, "signal number out of range");
return NULL; return (PyObject *)NULL;
} }
if (obj == sig_ign_object) if (obj == PySignal_SignalIgnoreHandler)
func = SIG_IGN; func = SIG_IGN;
else if (obj == sig_dfl_object) else if (obj == PySignal_SignalDefaultHandler)
func = SIG_DFL; func = SIG_DFL;
else if (!is_methodobject(obj) && else if (!PyCFunction_Check(obj) &&
!is_funcobject(obj) && !PyFunction_Check(obj) &&
!is_instancemethodobject(obj)) { !PyMethod_Check(obj)) {
err_setstr(TypeError, PyErr_SetString(PyExc_TypeError,
"signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object"); "signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object");
return NULL; return (PyObject *)NULL;
} }
else else
func = signal_handler; func = PySignal_Handler;
if (signal(sig_num, func) == SIG_ERR) { if (signal(sig_num, func) == SIG_ERR) {
err_errno(RuntimeError); PyErr_SetFromErrno(PyExc_RuntimeError);
return NULL; return (PyObject *)NULL;
} }
old_handler = sig_list[sig_num].func; old_handler = PySignal_SignalHandlerArray[sig_num].func;
sig_list[sig_num].tripped = 0; PySignal_SignalHandlerArray[sig_num].tripped = 0;
INCREF(obj); Py_INCREF(obj);
sig_list[sig_num].func = obj; PySignal_SignalHandlerArray[sig_num].func = obj;
return old_handler; return old_handler;
} }
static object * static PyObject *
signal_getsignal(self, args) PySignal_GetSignal(self, args)
object *self; /* Not used */ PyObject *self; /* Not used */
object *args; PyObject *args;
{ {
int sig_num; int sig_num;
object *old_handler; PyObject *old_handler;
if (!getargs(args, "i", &sig_num)) if (!PyArg_Parse(args, "i", &sig_num))
return NULL; return (PyObject *)NULL;
if (sig_num < 1 || sig_num >= NSIG) { if (sig_num < 1 || sig_num >= NSIG) {
err_setstr(ValueError, "signal number out of range"); PyErr_SetString(PyExc_ValueError, "signal number out of range");
return NULL; return (PyObject *)NULL;
} }
old_handler = sig_list[sig_num].func; old_handler = PySignal_SignalHandlerArray[sig_num].func;
INCREF(old_handler); Py_INCREF(old_handler);
return old_handler; return old_handler;
} }
/* List of functions defined in the module */ /* List of functions defined in the module */
static struct methodlist signal_methods[] = { static PyMethodDef PySignal_methods[] = {
{"alarm", signal_alarm}, {"alarm", PySignal_Alarm},
{"signal", signal_signal}, {"signal", PySignal_Signal},
{"getsignal", signal_getsignal}, {"getsignal", PySignal_GetSignal},
{"pause", signal_pause}, {"pause", PySignal_Pause},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
void void
initsignal() initsignal()
{ {
object *m, *d, *x; PyObject *m, *d, *x;
object *b_dict; PyObject *b_dict;
int i; int i;
#ifdef WITH_THREAD #ifdef WITH_THREAD
...@@ -217,218 +222,218 @@ initsignal() ...@@ -217,218 +222,218 @@ initsignal()
#endif #endif
/* Create the module and add the functions */ /* Create the module and add the functions */
m = initmodule("signal", signal_methods); m = Py_InitModule("signal", PySignal_methods);
/* Add some symbolic constants to the module */ /* Add some symbolic constants to the module */
d = getmoduledict(m); d = PyModule_GetDict(m);
sig_dfl_object = newintobject((long)SIG_DFL); PySignal_SignalDefaultHandler = PyInt_FromLong((long)SIG_DFL);
dictinsert(d, "SIG_DFL", sig_dfl_object); PyDict_SetItemString(d, "SIG_DFL", PySignal_SignalDefaultHandler);
sig_ign_object = newintobject((long)SIG_IGN); PySignal_SignalIgnoreHandler = PyInt_FromLong((long)SIG_IGN);
dictinsert(d, "SIG_IGN", sig_ign_object); PyDict_SetItemString(d, "SIG_IGN", PySignal_SignalIgnoreHandler);
dictinsert(d, "NSIG", newintobject((long)NSIG)); PyDict_SetItemString(d, "NSIG", PyInt_FromLong((long)NSIG));
default_int_handler_object = newmethodobject("default_int_handler", PySignal_DefaultIntHandler = PyCFunction_New("default_int_handler",
default_int_handler, PySignal_CDefaultIntHandler,
(object *)NULL, (PyObject *)NULL,
0); 0);
dictinsert(d, "default_int_handler", default_int_handler_object); PyDict_SetItemString(d, "default_int_handler", PySignal_DefaultIntHandler);
sig_list[0].tripped = 0; PySignal_SignalHandlerArray[0].tripped = 0;
for (i = 1; i < NSIG; i++) { for (i = 1; i < NSIG; i++) {
RETSIGTYPE (*t)(); RETSIGTYPE (*t)();
t = signal(i, SIG_IGN); t = signal(i, SIG_IGN);
signal(i, t); signal(i, t);
sig_list[i].tripped = 0; PySignal_SignalHandlerArray[i].tripped = 0;
if (t == SIG_DFL) if (t == SIG_DFL)
sig_list[i].func = sig_dfl_object; PySignal_SignalHandlerArray[i].func = PySignal_SignalDefaultHandler;
else if (t == SIG_IGN) else if (t == SIG_IGN)
sig_list[i].func = sig_ign_object; PySignal_SignalHandlerArray[i].func = PySignal_SignalIgnoreHandler;
else else
sig_list[i].func = None; /* None of our business */ PySignal_SignalHandlerArray[i].func = Py_None; /* None of our business */
INCREF(sig_list[i].func); Py_INCREF(PySignal_SignalHandlerArray[i].func);
} }
if (sig_list[SIGINT].func == sig_dfl_object) { if (PySignal_SignalHandlerArray[SIGINT].func == PySignal_SignalDefaultHandler) {
/* Install default int handler */ /* Install default int handler */
DECREF(sig_list[SIGINT].func); Py_DECREF(PySignal_SignalHandlerArray[SIGINT].func);
sig_list[SIGINT].func = default_int_handler_object; PySignal_SignalHandlerArray[SIGINT].func = PySignal_DefaultIntHandler;
INCREF(default_int_handler_object); Py_INCREF(PySignal_DefaultIntHandler);
signal(SIGINT, &signal_handler); signal(SIGINT, &PySignal_Handler);
} }
#ifdef SIGHUP #ifdef SIGHUP
x = newintobject(SIGHUP); x = PyInt_FromLong(SIGHUP);
dictinsert(d, "SIGHUP", x); PyDict_SetItemString(d, "SIGHUP", x);
#endif #endif
#ifdef SIGINT #ifdef SIGINT
x = newintobject(SIGINT); x = PyInt_FromLong(SIGINT);
dictinsert(d, "SIGINT", x); PyDict_SetItemString(d, "SIGINT", x);
#endif #endif
#ifdef SIGQUIT #ifdef SIGQUIT
x = newintobject(SIGQUIT); x = PyInt_FromLong(SIGQUIT);
dictinsert(d, "SIGQUIT", x); PyDict_SetItemString(d, "SIGQUIT", x);
#endif #endif
#ifdef SIGILL #ifdef SIGILL
x = newintobject(SIGILL); x = PyInt_FromLong(SIGILL);
dictinsert(d, "SIGILL", x); PyDict_SetItemString(d, "SIGILL", x);
#endif #endif
#ifdef SIGTRAP #ifdef SIGTRAP
x = newintobject(SIGTRAP); x = PyInt_FromLong(SIGTRAP);
dictinsert(d, "SIGTRAP", x); PyDict_SetItemString(d, "SIGTRAP", x);
#endif #endif
#ifdef SIGIOT #ifdef SIGIOT
x = newintobject(SIGIOT); x = PyInt_FromLong(SIGIOT);
dictinsert(d, "SIGIOT", x); PyDict_SetItemString(d, "SIGIOT", x);
#endif #endif
#ifdef SIGABRT #ifdef SIGABRT
x = newintobject(SIGABRT); x = PyInt_FromLong(SIGABRT);
dictinsert(d, "SIGABRT", x); PyDict_SetItemString(d, "SIGABRT", x);
#endif #endif
#ifdef SIGEMT #ifdef SIGEMT
x = newintobject(SIGEMT); x = PyInt_FromLong(SIGEMT);
dictinsert(d, "SIGEMT", x); PyDict_SetItemString(d, "SIGEMT", x);
#endif #endif
#ifdef SIGFPE #ifdef SIGFPE
x = newintobject(SIGFPE); x = PyInt_FromLong(SIGFPE);
dictinsert(d, "SIGFPE", x); PyDict_SetItemString(d, "SIGFPE", x);
#endif #endif
#ifdef SIGKILL #ifdef SIGKILL
x = newintobject(SIGKILL); x = PyInt_FromLong(SIGKILL);
dictinsert(d, "SIGKILL", x); PyDict_SetItemString(d, "SIGKILL", x);
#endif #endif
#ifdef SIGBUS #ifdef SIGBUS
x = newintobject(SIGBUS); x = PyInt_FromLong(SIGBUS);
dictinsert(d, "SIGBUS", x); PyDict_SetItemString(d, "SIGBUS", x);
#endif #endif
#ifdef SIGSEGV #ifdef SIGSEGV
x = newintobject(SIGSEGV); x = PyInt_FromLong(SIGSEGV);
dictinsert(d, "SIGSEGV", x); PyDict_SetItemString(d, "SIGSEGV", x);
#endif #endif
#ifdef SIGSYS #ifdef SIGSYS
x = newintobject(SIGSYS); x = PyInt_FromLong(SIGSYS);
dictinsert(d, "SIGSYS", x); PyDict_SetItemString(d, "SIGSYS", x);
#endif #endif
#ifdef SIGPIPE #ifdef SIGPIPE
x = newintobject(SIGPIPE); x = PyInt_FromLong(SIGPIPE);
dictinsert(d, "SIGPIPE", x); PyDict_SetItemString(d, "SIGPIPE", x);
#endif #endif
#ifdef SIGALRM #ifdef SIGALRM
x = newintobject(SIGALRM); x = PyInt_FromLong(SIGALRM);
dictinsert(d, "SIGALRM", x); PyDict_SetItemString(d, "SIGALRM", x);
#endif #endif
#ifdef SIGTERM #ifdef SIGTERM
x = newintobject(SIGTERM); x = PyInt_FromLong(SIGTERM);
dictinsert(d, "SIGTERM", x); PyDict_SetItemString(d, "SIGTERM", x);
#endif #endif
#ifdef SIGUSR1 #ifdef SIGUSR1
x = newintobject(SIGUSR1); x = PyInt_FromLong(SIGUSR1);
dictinsert(d, "SIGUSR1", x); PyDict_SetItemString(d, "SIGUSR1", x);
#endif #endif
#ifdef SIGUSR2 #ifdef SIGUSR2
x = newintobject(SIGUSR2); x = PyInt_FromLong(SIGUSR2);
dictinsert(d, "SIGUSR2", x); PyDict_SetItemString(d, "SIGUSR2", x);
#endif #endif
#ifdef SIGCLD #ifdef SIGCLD
x = newintobject(SIGCLD); x = PyInt_FromLong(SIGCLD);
dictinsert(d, "SIGCLD", x); PyDict_SetItemString(d, "SIGCLD", x);
#endif #endif
#ifdef SIGCHLD #ifdef SIGCHLD
x = newintobject(SIGCHLD); x = PyInt_FromLong(SIGCHLD);
dictinsert(d, "SIGCHLD", x); PyDict_SetItemString(d, "SIGCHLD", x);
#endif #endif
#ifdef SIGPWR #ifdef SIGPWR
x = newintobject(SIGPWR); x = PyInt_FromLong(SIGPWR);
dictinsert(d, "SIGPWR", x); PyDict_SetItemString(d, "SIGPWR", x);
#endif #endif
#ifdef SIGIO #ifdef SIGIO
x = newintobject(SIGIO); x = PyInt_FromLong(SIGIO);
dictinsert(d, "SIGIO", x); PyDict_SetItemString(d, "SIGIO", x);
#endif #endif
#ifdef SIGURG #ifdef SIGURG
x = newintobject(SIGURG); x = PyInt_FromLong(SIGURG);
dictinsert(d, "SIGURG", x); PyDict_SetItemString(d, "SIGURG", x);
#endif #endif
#ifdef SIGWINCH #ifdef SIGWINCH
x = newintobject(SIGWINCH); x = PyInt_FromLong(SIGWINCH);
dictinsert(d, "SIGWINCH", x); PyDict_SetItemString(d, "SIGWINCH", x);
#endif #endif
#ifdef SIGPOLL #ifdef SIGPOLL
x = newintobject(SIGPOLL); x = PyInt_FromLong(SIGPOLL);
dictinsert(d, "SIGPOLL", x); PyDict_SetItemString(d, "SIGPOLL", x);
#endif #endif
#ifdef SIGSTOP #ifdef SIGSTOP
x = newintobject(SIGSTOP); x = PyInt_FromLong(SIGSTOP);
dictinsert(d, "SIGSTOP", x); PyDict_SetItemString(d, "SIGSTOP", x);
#endif #endif
#ifdef SIGTSTP #ifdef SIGTSTP
x = newintobject(SIGTSTP); x = PyInt_FromLong(SIGTSTP);
dictinsert(d, "SIGTSTP", x); PyDict_SetItemString(d, "SIGTSTP", x);
#endif #endif
#ifdef SIGCONT #ifdef SIGCONT
x = newintobject(SIGCONT); x = PyInt_FromLong(SIGCONT);
dictinsert(d, "SIGCONT", x); PyDict_SetItemString(d, "SIGCONT", x);
#endif #endif
#ifdef SIGTTIN #ifdef SIGTTIN
x = newintobject(SIGTTIN); x = PyInt_FromLong(SIGTTIN);
dictinsert(d, "SIGTTIN", x); PyDict_SetItemString(d, "SIGTTIN", x);
#endif #endif
#ifdef SIGTTOU #ifdef SIGTTOU
x = newintobject(SIGTTOU); x = PyInt_FromLong(SIGTTOU);
dictinsert(d, "SIGTTOU", x); PyDict_SetItemString(d, "SIGTTOU", x);
#endif #endif
#ifdef SIGVTALRM #ifdef SIGVTALRM
x = newintobject(SIGVTALRM); x = PyInt_FromLong(SIGVTALRM);
dictinsert(d, "SIGVTALRM", x); PyDict_SetItemString(d, "SIGVTALRM", x);
#endif #endif
#ifdef SIGPROF #ifdef SIGPROF
x = newintobject(SIGPROF); x = PyInt_FromLong(SIGPROF);
dictinsert(d, "SIGPROF", x); PyDict_SetItemString(d, "SIGPROF", x);
#endif #endif
#ifdef SIGCPU #ifdef SIGCPU
x = newintobject(SIGCPU); x = PyInt_FromLong(SIGCPU);
dictinsert(d, "SIGCPU", x); PyDict_SetItemString(d, "SIGCPU", x);
#endif #endif
#ifdef SIGFSZ #ifdef SIGFSZ
x = newintobject(SIGFSZ); x = PyInt_FromLong(SIGFSZ);
dictinsert(d, "SIGFSZ", x); PyDict_SetItemString(d, "SIGFSZ", x);
#endif #endif
/* Check for errors */ /* Check for errors */
if (err_occurred()) if (PyErr_Occurred())
fatal("can't initialize module signal"); Py_FatalError("can't initialize module signal");
} }
int int
sigcheck() sigcheck()
{ {
int i; int i;
object *f; PyObject *f;
if (!tripped) if (!PySignal_IsTripped)
return 0; return 0;
#ifdef WITH_THREAD #ifdef WITH_THREAD
if (get_thread_ident() != main_thread) if (get_thread_ident() != main_thread)
return 0; return 0;
#endif #endif
f = getframe(); f = getframe();
if (f == NULL) if (f == (PyObject *)NULL)
f = None; f = Py_None;
for (i = 1; i < NSIG; i++) { for (i = 1; i < NSIG; i++) {
if (sig_list[i].tripped) { if (PySignal_SignalHandlerArray[i].tripped) {
object *arglist, *result; PyObject *arglist, *result;
sig_list[i].tripped = 0; PySignal_SignalHandlerArray[i].tripped = 0;
arglist = mkvalue("(iO)", i, f); arglist = Py_BuildValue("(iO)", i, f);
if (arglist == NULL) if (arglist == (PyObject *)NULL)
result = NULL; result = (PyObject *)NULL;
else { else {
result = call_object(sig_list[i].func,arglist); result = PyEval_CallObject(PySignal_SignalHandlerArray[i].func,arglist);
DECREF(arglist); Py_DECREF(arglist);
} }
if (result == NULL) { if (result == (PyObject *)NULL) {
return 1; return 1;
} else { } else {
DECREF(result); Py_DECREF(result);
} }
} }
} }
tripped = 0; PySignal_IsTripped = 0;
return 0; return 0;
} }
...@@ -443,12 +448,12 @@ initintr() ...@@ -443,12 +448,12 @@ initintr()
int int
intrcheck() intrcheck()
{ {
if (sig_list[SIGINT].tripped) { if (PySignal_SignalHandlerArray[SIGINT].tripped) {
#ifdef WITH_THREAD #ifdef WITH_THREAD
if (get_thread_ident() != main_thread) if (get_thread_ident() != main_thread)
return 0; return 0;
#endif #endif
sig_list[SIGINT].tripped = 0; PySignal_SignalHandlerArray[SIGINT].tripped = 0;
return 1; return 1;
} }
return 0; return 0;
......
...@@ -63,6 +63,7 @@ Socket methods: ...@@ -63,6 +63,7 @@ Socket methods:
- s.recvfrom(nbytes [,flags]) --> string, sockaddr - s.recvfrom(nbytes [,flags]) --> string, sockaddr
- s.send(string [,flags]) --> nbytes - s.send(string [,flags]) --> nbytes
- s.sendto(string, [flags,] sockaddr) --> nbytes - s.sendto(string, [flags,] sockaddr) --> nbytes
- s.setblocking(1 | 0) --> None
- s.shutdown(how) --> None - s.shutdown(how) --> None
- s.close() --> None - s.close() --> None
...@@ -80,6 +81,7 @@ Socket methods: ...@@ -80,6 +81,7 @@ Socket methods:
#include <netdb.h> #include <netdb.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <fcntl.h>
#else #else
#include <winsock.h> #include <winsock.h>
#endif #endif
...@@ -441,6 +443,34 @@ BUILD_FUNC_DEF_2(sock_allowbroadcast,sockobject *,s, object *,args) ...@@ -441,6 +443,34 @@ BUILD_FUNC_DEF_2(sock_allowbroadcast,sockobject *,s, object *,args)
#endif #endif
#ifndef NT
/* s.setblocking(1 | 0) method */
static object *
sock_setblocking(s, args)
sockobject *s;
object *args;
{
int block;
int delay_flag;
if (!getintarg(args, &block))
return NULL;
BGN_SAVE
delay_flag = fcntl (s->sock_fd, F_GETFL, 0);
if (block)
delay_flag &= (~O_NDELAY);
else
delay_flag |= O_NDELAY;
fcntl (s->sock_fd, F_SETFL, delay_flag);
END_SAVE
INCREF(None);
return None;
}
#endif
/* s.setsockopt() method. /* s.setsockopt() method.
With an integer third argument, sets an integer option. With an integer third argument, sets an integer option.
With a string third argument, sets an option from a buffer; With a string third argument, sets an option from a buffer;
...@@ -812,6 +842,9 @@ static struct methodlist sock_methods[] = { ...@@ -812,6 +842,9 @@ static struct methodlist sock_methods[] = {
{"accept", (method)sock_accept}, {"accept", (method)sock_accept},
#if 0 #if 0
{"allowbroadcast", (method)sock_allowbroadcast}, {"allowbroadcast", (method)sock_allowbroadcast},
#endif
#ifndef NT
{"setblocking", (method)sock_setblocking},
#endif #endif
{"setsockopt", (method)sock_setsockopt}, {"setsockopt", (method)sock_setsockopt},
{"getsockopt", (method)sock_getsockopt}, {"getsockopt", (method)sock_getsockopt},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment