[ovs-dev] ovsdb-idlc.in: fix dict change during iteration.
diff mbox series

Message ID 20190914231728.6871-1-fbl@sysclose.org
State New
Headers show
Series
  • [ovs-dev] ovsdb-idlc.in: fix dict change during iteration.
Related show

Commit Message

Sriram Vatala via dev Sept. 14, 2019, 11:17 p.m. UTC
Python3 complains if a dict key is changed during the
iteration.

Use list() to create a copy of it.

Traceback (most recent call last):
  File "./ovsdb/ovsdb-idlc.in", line 1581, in <module>
    func(*args[1:])
  File "./ovsdb/ovsdb-idlc.in", line 185, in printCIDLHeader
    replace_cplusplus_keyword(schema)
  File "./ovsdb/ovsdb-idlc.in", line 179, in replace_cplusplus_keyword
    for columnName in table.columns:
RuntimeError: dictionary keys changed during iteration

Signed-off-by: Flavio Leitner <fbl@sysclose.org>
---
 ovsdb/ovsdb-idlc.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff Sept. 24, 2019, 8:06 p.m. UTC | #1
On Sat, Sep 14, 2019 at 08:17:28PM -0300, Flavio Leitner via dev wrote:
> Python3 complains if a dict key is changed during the
> iteration.
> 
> Use list() to create a copy of it.

Thanks!  Applied to master.

Patch
diff mbox series

diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 40fef39ed..22d0a4e22 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -176,7 +176,7 @@  def replace_cplusplus_keyword(schema):
                 'wchar_t', 'while', 'xor', 'xor_eq'}
 
     for tableName, table in schema.tables.items():
-        for columnName in table.columns:
+        for columnName in list(table.columns):
             if columnName in keywords:
                 table.columns[columnName + '_'] = table.columns.pop(columnName)