-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed as not planned
Labels
Description
Proposal:
# Add a code block here, if required
from #125958
The indentation of the preprocessor generated by clinic seems strange, it puts the preprocessor and normal statements in the same column. This makes it less readable, even if it is generated, which can maintain correctness, but it does not exclude that no developer will read the code.
for example:
cpython/Modules/_posixsubprocess.c
Lines 569 to 580 in 75401fe
static void | |
_close_open_fds(int start_fd, int *fds_to_keep, Py_ssize_t fds_to_keep_len) | |
{ | |
#ifdef HAVE_ASYNC_SAFE_CLOSE_RANGE | |
if (_close_range_except( | |
start_fd, INT_MAX, fds_to_keep, fds_to_keep_len, | |
_close_range_closer) == 0) { | |
return; | |
} | |
#endif | |
_close_open_fds_fallback(start_fd, fds_to_keep, fds_to_keep_len); | |
} |
This is easy to understand for indentation.
The following clinic generated code:
tatic PyObject *
cmath_acosh(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 1
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
PyObject *ob_item[NUM_KEYWORDS];
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_item = { _Py_LATIN1_CHR('z'), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
#else // !Py_BUILD_CORE
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
static const char * const _keywords[] = {"z", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "acosh",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
PyObject *argsbuf[1];
Py_complex z;
Py_complex _return_value;
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
if (!args) {
goto exit;
}
z = PyComplex_AsCComplex(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
@@ -93,25 +153,55 @@ cmath_acosh(PyObject *module, PyObject *arg)
}
Forgive me for not seeing the preprocessor at first glance. If it was not designed with reading in mind, I will close this PR.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response