[buildobjs] deal with py3k's dict method changes

Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset6e198fcda807
branchdefault
phasedraft
hiddenyes
parent revision#e092f2799bfc [exceptions] don't use dict.iteritems
child revision#1caba7747cc2 Deal with python3's dict method changes
files modified by this revision
buildobjs.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1413450156 -7200
# Thu Oct 16 11:02:36 2014 +0200
# Node ID 6e198fcda807be0a7ad0ca36cc20742d3b9489dd
# Parent e092f2799bfc35543476cd17fdba66d6d7b74f6e
[buildobjs] deal with py3k's dict method changes

Related to #267910.

diff --git a/buildobjs.py b/buildobjs.py
@@ -79,11 +79,11 @@
1          rdef.name = name
2      if insertidx is None:
3          insertidx = len(relations)
4      relations.insert(insertidx, rdef)
5      if getattr(rdef, 'metadata', {}):
6 -        for meta_name, value in rdef.metadata.iteritems():
7 +        for meta_name, value in rdef.metadata.items():
8              assert meta_name in KNOWN_METAATTRIBUTES
9              insertidx += 1 # insert meta after main
10              meta_rel_name = '_'.join(((name or rdef.name), meta_name))
11              _add_relation(relations, value, meta_rel_name, insertidx)
12 
@@ -357,11 +357,11 @@
13      stacklevel = 3
14      def __new__(mcs, name, bases, classdict):
15          ### Move (any) relation from the class dict to __relations__ attribute
16          rels = classdict.setdefault('__relations__', [])
17          relations = dict((rdef.name, rdef) for rdef in rels)
18 -        for rname, rdef in classdict.items():
19 +        for rname, rdef in list(classdict.items()):
20              if isinstance(rdef, ObjectRelation):
21                  # relation's name **must** be removed from class namespace
22                  # to avoid conflicts with instance's potential attributes
23                  del classdict[rname]
24                  relations[rname] = rdef