[Python-checkins] CVS: python/dist/src/Modules termios.c,2.26,2.27
Fred L. Drake
fdrake@users.sourceforge.net
Wed, 09 May 2001 13:14:11 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv13546/Modules
Modified Files:
termios.c
Log Message:
fdconv(): Do not second guess the error condition returned by
PyObject_AsFileDescriptor() -- it does the same thing everywhere, so
use it the same way everyone else does so that exceptions are
consistent. This means we have less code here, and we do not need to
resort to hackish ways of getting the Python-visible function name to
fdconv().
Index: termios.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/termios.c,v
retrieving revision 2.26
retrieving revision 2.27
diff -C2 -r2.26 -r2.27
*** termios.c 2001/05/09 17:53:06 2.26
--- termios.c 2001/05/09 20:14:09 2.27
***************
*** 29,34 ****
static PyObject *TermiosError;
- static char* fname;
-
static int fdconv(PyObject* obj, void* p)
{
--- 29,32 ----
***************
*** 36,63 ****
fd = PyObject_AsFileDescriptor(obj);
! if (fd == -1) {
! if (PyInt_Check(obj)) {
! fd = PyInt_AS_LONG(obj);
! }
! else {
! char* tname;
!
! if (PyInstance_Check(obj)) {
! tname = PyString_AS_STRING(
! ((PyInstanceObject*)obj)->in_class->cl_name);
! }
! else {
! tname = obj->ob_type->tp_name;
! }
!
! PyErr_Format(PyExc_TypeError,
! "%s, arg 1: can't extract file descriptor from \"%.500s\"",
! fname, tname);
! return 0;
! }
}
!
! *(int*)p = fd;
! return 1;
}
--- 34,42 ----
fd = PyObject_AsFileDescriptor(obj);
! if (fd >= 0) {
! *(int*)p = fd;
! return 1;
}
! return 0;
}
***************
*** 84,89 ****
char ch;
- fname = "tcgetattr";
-
if (!PyArg_ParseTuple(args, "O&:tcgetattr",
fdconv, (void*)&fd))
--- 63,66 ----
***************
*** 161,166 ****
int i;
- fname = "tcsetattr";
-
if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
fdconv, &fd, &when, &term))
--- 138,141 ----
***************
*** 229,234 ****
int fd, duration;
- fname = "tcsendbreak";
-
if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
fdconv, &fd, &duration))
--- 204,207 ----
***************
*** 251,256 ****
int fd;
- fname = "tcdrain";
-
if (!PyArg_ParseTuple(args, "O&:tcdrain",
fdconv, &fd))
--- 224,227 ----
***************
*** 276,281 ****
int fd, queue;
- fname = "tcflush";
-
if (!PyArg_ParseTuple(args, "O&i:tcflush",
fdconv, &fd, &queue))
--- 247,250 ----
***************
*** 300,305 ****
{
int fd, action;
-
- fname = "tcflow";
if (!PyArg_ParseTuple(args, "O&i:tcflow",
--- 269,272 ----