[Idle-dev] CVS: idle interruptmodule.c,NONE,1.1 setup.py,1.13,1.14
Kurt B. Kaiser
kbk@users.sourceforge.net
Mon, 10 Mar 2003 12:41:12 -0800
Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv20028
Modified Files:
setup.py
Added Files:
interruptmodule.c
Log Message:
A interruptmodule.c
M setup.py
Implements an interrupt extension module which allows a subthread
to raise an interrupt in the main thread.
--- NEW FILE: interruptmodule.c ---
/***********************************************************************
* interruptmodule.c
*
* Python extension implementing the interrupt module.
*
**********************************************************************/
#include "Python.h"
#ifndef PyDoc_STR
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STR(str) str
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#endif
/* module documentation */
PyDoc_STRVAR(module_doc,
"Provide a way to interrupt the main thread from a subthread.\n\n\
In threaded Python code the KeyboardInterrupt is always directed to\n\
the thread which raised it. This extension provides a method,\n\
interrupt_main, which a subthread can use to raise a KeyboardInterrupt\n\
in the main thread.");
/* module functions */
static PyObject *
setinterrupt(PyObject * self, PyObject * args)
{
PyErr_SetInterrupt();
Py_INCREF(Py_None);
return Py_None;
}
/* registration table */
static struct PyMethodDef methods[] = {
{"interrupt_main", setinterrupt, METH_VARARGS,
PyDoc_STR("Interrupt the main thread")},
{NULL, NULL}
};
/* module initialization */
void
initinterrupt(void)
{
(void) Py_InitModule3("interrupt", methods, module_doc);
}
Index: setup.py
===================================================================
RCS file: /cvsroot/idlefork/idle/setup.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** setup.py 21 Jan 2003 04:42:50 -0000 1.13
--- setup.py 10 Mar 2003 20:41:07 -0000 1.14
***************
*** 1,4 ****
import os, glob, sys
! from distutils.core import setup
from distutils.command.build_py import build_py
from distutils.command.install_lib import install_lib
--- 1,4 ----
import os, glob, sys
! from distutils.core import setup, Extension
from distutils.command.build_py import build_py
from distutils.command.install_lib import install_lib
***************
*** 112,115 ****
--- 112,116 ----
package_dir = {pkgname: pkg_dir},
packages = [pkgname],
+ ext_modules = [Extension("interrupt", ["interruptmodule.c"])],
scripts = [os.path.join(pkg_dir, idle_name)]
)