summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-07-16 13:42:04 (GMT)
committerGitHub <noreply@github.com>2021-07-16 13:42:04 (GMT)
commit80844d1ebc03e1cf3ffdeb47751522499e90b0bc (patch)
tree64e11d4c53ffbb06ae033b3ceffb7b305c82a359 /Objects
parent948e39a866ccf33b4e30668c3f88a95a65966159 (diff)
downloadcpython-80844d1ebc03e1cf3ffdeb47751522499e90b0bc.zip
cpython-80844d1ebc03e1cf3ffdeb47751522499e90b0bc.tar.gz
cpython-80844d1ebc03e1cf3ffdeb47751522499e90b0bc.tar.bz2
[3.10] bpo-44652: Preserve natural order of args in the union type. (GH-27185) (GH-27190)
(cherry picked from commit 0cd2d51aadcd2a0c0739a5df0a6235d64f35619e) Automerge-Triggered-By: GH:ambv
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unionobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/unionobject.c b/Objects/unionobject.c
index f3e0aa6..15cd6c5 100644
--- a/Objects/unionobject.c
+++ b/Objects/unionobject.c
@@ -257,8 +257,8 @@ dedup_and_flatten_args(PyObject* args)
for (Py_ssize_t i = 0; i < arg_length; i++) {
int is_duplicate = 0;
PyObject* i_element = PyTuple_GET_ITEM(args, i);
- for (Py_ssize_t j = i + 1; j < arg_length; j++) {
- PyObject* j_element = PyTuple_GET_ITEM(args, j);
+ for (Py_ssize_t j = 0; j < added_items; j++) {
+ PyObject* j_element = PyTuple_GET_ITEM(new_args, j);
int is_ga = PyObject_TypeCheck(i_element, &Py_GenericAliasType) &&
PyObject_TypeCheck(j_element, &Py_GenericAliasType);
// RichCompare to also deduplicate GenericAlias types (slower)