diff --git a/Misc/NEWS.d/next/Tools-Demos/2026-08-05-14-02-55.gh-issue-155218.Nq4xZv.rst b/Misc/NEWS.d/next/Tools-Demos/2026-08-05-14-02-55.gh-issue-155218.Nq4xZv.rst new file mode 100644 index 000000000000000..909efc558693c0a --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2026-08-05-14-02-55.gh-issue-155218.Nq4xZv.rst @@ -0,0 +1,2 @@ +Fix Argument Clinic generating the flags of the optional groups in +different order on 32-bit and 64-bit platforms. diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h index 0d2237241260eb6..93fd98610c198d4 100644 --- a/Modules/clinic/_cursesmodule.c.h +++ b/Modules/clinic/_cursesmodule.c.h @@ -67,8 +67,8 @@ _curses_window_addch(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 1 to 4 arguments"); @@ -139,8 +139,8 @@ _curses_window_addstr(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOl:addstr", &y, &x, &str, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments"); @@ -214,8 +214,8 @@ _curses_window_addnstr(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOil:addnstr", &y, &x, &str, &n, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments"); @@ -949,8 +949,8 @@ _curses_window_hline(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOil:hline", &y, &x, &ch, &n, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.hline requires 2 to 5 arguments"); @@ -1019,8 +1019,8 @@ _curses_window_insch(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOl:insch", &y, &x, &ch, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.insch requires 1 to 4 arguments"); @@ -1138,8 +1138,8 @@ _curses_window_insstr(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOl:insstr", &y, &x, &str, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.insstr requires 1 to 4 arguments"); @@ -1215,8 +1215,8 @@ _curses_window_insnstr(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOil:insnstr", &y, &x, &str, &n, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.insnstr requires 2 to 5 arguments"); @@ -1826,8 +1826,8 @@ _curses_window_vline(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "iiOil:vline", &y, &x, &ch, &n, &attr)) { goto exit; } - group_right_1 = 1; group_left_1 = 1; + group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 2 to 5 arguments"); @@ -4486,4 +4486,4 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored #ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */ -/*[clinic end generated code: output=c1b7520d331d3d61 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=537ca9e700991cdd input=a9049054013a1b77]*/ diff --git a/Tools/clinic/libclinic/clanguage.py b/Tools/clinic/libclinic/clanguage.py index 7f02c7790f015aa..dbe32fbd951b7a6 100644 --- a/Tools/clinic/libclinic/clanguage.py +++ b/Tools/clinic/libclinic/clanguage.py @@ -320,7 +320,9 @@ def render_option_group_parsing( """) continue - group_ids = {p.group for p in subset} # eliminate duplicates + # A set would eliminate duplicates too, but the iteration + # order of small negative integers depends on the platform. + group_ids = dict.fromkeys(p.group for p in subset) d: dict[str, str | int] = {} d['count'] = count d['name'] = f.name @@ -331,7 +333,7 @@ def render_option_group_parsing( p.converter.parse_argument(parse_arguments) d['parse_arguments'] = ", ".join(parse_arguments) - group_ids.discard(0) + group_ids.pop(0, None) lines = "\n".join([ self.group_to_variable_name(g) + " = 1;" for g in group_ids