From: sergeyb@tarantool.org To: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org, lvasiliev@tarantool.org Subject: [Tarantool-patches] [PATCH v3 2/5] test: make dict.items() compatible with Python 3.x Date: Wed, 23 Dec 2020 15:36:06 +0300 [thread overview] Message-ID: <d9067a16fdfd6d57a617248d66ff120f0618dcc1.1608726409.git.estetus@gmail.com> (raw) In-Reply-To: <cover.1608726409.git.estetus@gmail.com> From: Sergey Bronnikov <sergeyb@tarantool.org> In Python 2.x calling items() makes a copy of the keys that you can iterate over while modifying the dict. This doesn't work in Python 3.x because items() returns an iterator instead of a list and Python 3 raise an exception "dictionary changed size during iteration". To workaround it one can use list to force a copy of the keys to be made. Part of #5538 --- test/box-py/iproto.test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/box-py/iproto.test.py b/test/box-py/iproto.test.py index 6ed49051b..6723e03f5 100644 --- a/test/box-py/iproto.test.py +++ b/test/box-py/iproto.test.py @@ -37,7 +37,7 @@ print(iproto.py_con.ping() > 0) s.close() key_names = {} -for (k,v) in globals().items(): +for (k,v) in list(globals().items()): if type(k) == str and k.startswith("IPROTO_") and type(v) == int: key_names[v] = k -- 2.25.1
next prev parent reply other threads:[~2020-12-23 12:36 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-23 12:36 [Tarantool-patches] [PATCH v3 0/5] Support Python 3 in tests and PEPify source code sergeyb 2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 1/5] test: convert print to function and make quotes use consistent sergeyb 2020-12-23 15:39 ` Vladislav Shpilevoy 2020-12-24 10:50 ` Sergey Bronnikov 2020-12-23 12:36 ` sergeyb [this message] 2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 3/5] test: make strings compatible with Python 3 sergeyb 2020-12-23 15:40 ` Vladislav Shpilevoy 2020-12-24 11:03 ` Sergey Bronnikov 2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 4/5] test: get rid of iteritems() sergeyb 2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 5/5] test: remove dead code in Python tests end extra newlines sergeyb 2020-12-23 23:42 ` [Tarantool-patches] [PATCH v3 0/5] Support Python 3 in tests and PEPify source code Leonid Vasiliev 2020-12-24 16:05 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=d9067a16fdfd6d57a617248d66ff120f0618dcc1.1608726409.git.estetus@gmail.com \ --to=sergeyb@tarantool.org \ --cc=lvasiliev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v3 2/5] test: make dict.items() compatible with Python 3.x' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox