1
1
/* termios.c -- POSIX terminal I/O module implementation. */
2
2
3
- #ifndef Py_BUILD_CORE_BUILTIN
4
- # define Py_BUILD_CORE_MODULE 1
3
+ // Need limited C API version 3.13 for PyLong_AsInt()
4
+ // in code generated by Argument Clinic.
5
+ #include "pyconfig.h" // Py_GIL_DISABLED
6
+ #ifndef Py_GIL_DISABLED
7
+ # define Py_LIMITED_API 0x030d0000
5
8
#endif
6
9
7
10
#include "Python.h"
8
11
12
+ #include <string.h> // memset()
13
+ #include <sys/ioctl.h>
14
+ #include <termios.h>
15
+ #include <unistd.h> // _POSIX_VDISABLE
16
+
9
17
// On QNX 6, struct termio must be declared by including sys/termio.h
10
18
// if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must
11
19
// be included before termios.h or it will generate an error.
19
27
# define CTRL (c ) ((c)&037)
20
28
#endif
21
29
30
+ // We could do better. Check bpo-32660
22
31
#if defined(__sun )
23
- /* We could do better. Check issue-32660 */
24
- #include <sys/filio.h>
25
- #include <sys/sockio.h>
32
+ # include <sys/filio.h>
33
+ # include <sys/sockio.h>
26
34
#endif
27
35
28
- #include <termios.h>
29
- #include <sys/ioctl.h>
30
- #include <unistd.h> // _POSIX_VDISABLE
31
-
32
36
/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
33
37
* MDTR, MRI, and MRTS (apparently used internally by some things
34
38
* defined as macros; these are not used here directly).
35
39
*/
36
40
#ifdef HAVE_SYS_MODEM_H
37
- #include <sys/modem.h>
41
+ # include <sys/modem.h>
38
42
#endif
43
+
39
44
/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */
40
45
#ifdef HAVE_SYS_BSDTTY_H
41
- #include <sys/bsdtty.h>
46
+ # include <sys/bsdtty.h>
42
47
#endif
43
48
49
+
44
50
/*[clinic input]
45
51
module termios
46
52
[clinic start generated code]*/
@@ -120,7 +126,7 @@ termios_tcgetattr_impl(PyObject *module, int fd)
120
126
v = PyBytes_FromStringAndSize (& ch , 1 );
121
127
if (v == NULL )
122
128
goto err ;
123
- PyList_SET_ITEM (cc , i , v );
129
+ PyList_SetItem (cc , i , v );
124
130
}
125
131
126
132
/* Convert the MIN and TIME slots to integer. On some systems, the
@@ -154,7 +160,7 @@ termios_tcgetattr_impl(PyObject *module, int fd)
154
160
Py_DECREF(v); \
155
161
goto err; \
156
162
} \
157
- PyList_SET_ITEM (v, index, l); \
163
+ PyList_SetItem (v, index, l); \
158
164
} while (0)
159
165
160
166
ADD_LONG_ITEM (0 , mode .c_iflag );
@@ -165,7 +171,7 @@ termios_tcgetattr_impl(PyObject *module, int fd)
165
171
ADD_LONG_ITEM (5 , ospeed );
166
172
#undef ADD_LONG_ITEM
167
173
168
- PyList_SET_ITEM (v , 6 , cc );
174
+ PyList_SetItem (v , 6 , cc );
169
175
return v ;
170
176
err :
171
177
Py_DECREF (cc );
@@ -214,7 +220,7 @@ termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term)
214
220
215
221
speed_t ispeed , ospeed ;
216
222
#define SET_FROM_LIST (TYPE , VAR , LIST , N ) do { \
217
- PyObject *item = PyList_GET_ITEM (LIST, N); \
223
+ PyObject *item = PyList_GetItem (LIST, N); \
218
224
long num = PyLong_AsLong(item); \
219
225
if (num == -1 && PyErr_Occurred()) { \
220
226
return NULL; \
@@ -230,7 +236,7 @@ termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term)
230
236
SET_FROM_LIST (speed_t , ospeed , term , 5 );
231
237
#undef SET_FROM_LIST
232
238
233
- PyObject * cc = PyList_GET_ITEM (term , 6 );
239
+ PyObject * cc = PyList_GetItem (term , 6 );
234
240
if (!PyList_Check (cc ) || PyList_Size (cc ) != NCCS ) {
235
241
PyErr_Format (PyExc_TypeError ,
236
242
"tcsetattr: attributes[6] must be %d element list" ,
0 commit comments