This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Need limited C API version 3.13 for PyLong_AsInt()
// in code generated by Argument Clinic.
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030d0000
#endif
#include "Python.h"
#include <string.h> // memset()
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h> // _POSIX_VDISABLE
// On QNX 6, struct termio must be declared by including sys/termio.h
// if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must
// be included before termios.h or it will generate an error.
Expand All
@@ -19,28 +27,26 @@
# define CTRL(c) ((c)&037)
#endif
// We could do better. Check bpo-32660
#if defined(__sun)
/* We could do better. Check issue-32660 */
#include <sys/filio.h>
#include <sys/sockio.h>
# include <sys/filio.h>
# include <sys/sockio.h>
#endif
#include <termios.h>
#include <sys/ioctl.h>
#include <unistd.h> // _POSIX_VDISABLE
/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
* MDTR, MRI, and MRTS (apparently used internally by some things
* defined as macros; these are not used here directly).
*/
#ifdef HAVE_SYS_MODEM_H
#include <sys/modem.h>
#include <sys/modem.h>
#endif
/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */
#ifdef HAVE_SYS_BSDTTY_H
#include <sys/bsdtty.h>
#include <sys/bsdtty.h>
#endif
/*[clinic input]
module termios
[clinic start generated code]*/
Expand Down
Expand Up
@@ -120,7 +126,7 @@ termios_tcgetattr_impl(PyObject *module, int fd)
v = PyBytes_FromStringAndSize(&ch, 1);
if (v == NULL)
goto err;
PyList_SET_ITEM(cc, i, v);
PyList_SetItem(cc, i, v);
}
/* Convert the MIN and TIME slots to integer. On some systems, the
Expand Down
Expand Up
@@ -154,7 +160,7 @@ termios_tcgetattr_impl(PyObject *module, int fd)
Py_DECREF(v); \
goto err; \
} \
PyList_SET_ITEM(v, index, l); \
PyList_SetItem(v, index, l); \
} while (0)
ADD_LONG_ITEM(0, mode.c_iflag);
Expand All
@@ -165,7 +171,7 @@ termios_tcgetattr_impl(PyObject *module, int fd)
ADD_LONG_ITEM(5, ospeed);
#undef ADD_LONG_ITEM
PyList_SET_ITEM(v, 6, cc);
PyList_SetItem(v, 6, cc);
return v;
err:
Py_DECREF(cc);
Expand Down
Expand Up
@@ -214,7 +220,7 @@ termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term)
speed_t ispeed, ospeed;
#define SET_FROM_LIST(TYPE, VAR, LIST, N) do { \
PyObject *item = PyList_GET_ITEM(LIST, N); \
PyObject *item = PyList_GetItem(LIST, N); \
long num = PyLong_AsLong(item); \
if (num == -1 && PyErr_Occurred()) { \
return NULL; \
Expand All
@@ -230,7 +236,7 @@ termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term)
SET_FROM_LIST(speed_t, ospeed, term, 5);
#undef SET_FROM_LIST
PyObject *cc = PyList_GET_ITEM(term, 6);
PyObject *cc = PyList_GetItem(term, 6);
if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
PyErr_Format(PyExc_TypeError,
"tcsetattr: attributes[6] must be %d element list",
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh-85283: Build termios extension with the limited C API #116928
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
gh-85283: Build termios extension with the limited C API #116928
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.