Use 'in' instead of 'has_key()' for testing dictionary membership.
In PEP 0290, has_key() was deprecated in Python 2.2 and higher: https://www.python.org/dev/peps/pep-0290/#testing-dictionary-membership https://docs.python.org/2.2/whatsnew/node4.html In Python 3, dict.has_key() was removed: https://docs.python.org/3.0/whatsnew/3.0.html#builtins
This commit is contained in:
parent
69527b11bb
commit
aef675d879
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291036
@ -461,7 +461,7 @@ def __init__(self, source):
|
|||||||
if (event.type == "pad"):
|
if (event.type == "pad"):
|
||||||
continue
|
continue
|
||||||
duration = event.duration
|
duration = event.duration
|
||||||
if (eventtypes.has_key(event.name)):
|
if (event.name in eventtypes):
|
||||||
(c, d) = eventtypes[event.name]
|
(c, d) = eventtypes[event.name]
|
||||||
c += 1
|
c += 1
|
||||||
d += duration
|
d += duration
|
||||||
@ -1069,7 +1069,7 @@ def checkstamp(self, timestamp):
|
|||||||
|
|
||||||
def makeid(self, group, id, type):
|
def makeid(self, group, id, type):
|
||||||
tag = group + id
|
tag = group + id
|
||||||
if (self.taghash.has_key(tag)):
|
if (tag in self.taghash):
|
||||||
return self.taghash[tag]
|
return self.taghash[tag]
|
||||||
if (type == "counter"):
|
if (type == "counter"):
|
||||||
source = Counter(group, id)
|
source = Counter(group, id)
|
||||||
|
@ -130,7 +130,7 @@ def __init__(self, enabled=True, stats=None):
|
|||||||
self.stats = stats
|
self.stats = stats
|
||||||
|
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
if self.enabled and self.items.has_key(id):
|
if self.enabled and id in self.items:
|
||||||
self.stats.hit += 1
|
self.stats.hit += 1
|
||||||
return self.items[id]
|
return self.items[id]
|
||||||
else:
|
else:
|
||||||
@ -139,7 +139,7 @@ def get(self, id):
|
|||||||
|
|
||||||
def put(self, id, obj):
|
def put(self, id, obj):
|
||||||
if self.enabled:
|
if self.enabled:
|
||||||
if self.items.has_key(id) and obj is not self.items[id]:
|
if id in self.items and obj is not self.items[id]:
|
||||||
#raise ValueError("Item is already cached: %d (%s, %s)" %
|
#raise ValueError("Item is already cached: %d (%s, %s)" %
|
||||||
# (id, self.items[id], obj))
|
# (id, self.items[id], obj))
|
||||||
warn(Config.w_cached, "Item is already cached: %d (%s, %s)" % \
|
warn(Config.w_cached, "Item is already cached: %d (%s, %s)" % \
|
||||||
@ -148,7 +148,7 @@ def put(self, id, obj):
|
|||||||
|
|
||||||
def replace(self, id, obj):
|
def replace(self, id, obj):
|
||||||
if self.enabled:
|
if self.enabled:
|
||||||
assert self.items.has_key(id)
|
assert id in self.items
|
||||||
self.items[id] = obj
|
self.items[id] = obj
|
||||||
|
|
||||||
class ListDiff(object):
|
class ListDiff(object):
|
||||||
@ -226,7 +226,7 @@ def __init__(self, name):
|
|||||||
self.symbols = {}
|
self.symbols = {}
|
||||||
|
|
||||||
def append(self, symbol):
|
def append(self, symbol):
|
||||||
if (self.symbols.has_key(symbol.name)):
|
if (symbol.name in self.symbols):
|
||||||
raise ValueError("Symbol is already defined %s@%s" %
|
raise ValueError("Symbol is already defined %s@%s" %
|
||||||
(symbol.name, self.name))
|
(symbol.name, self.name))
|
||||||
self.symbols[symbol.name] = symbol
|
self.symbols[symbol.name] = symbol
|
||||||
@ -250,7 +250,7 @@ def __init__(self, id, name, **kwargs):
|
|||||||
self.attrs = kwargs
|
self.attrs = kwargs
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
if not self.attrs.has_key(attr):
|
if attr not in self.attrs:
|
||||||
raise AttributeError('%s in %s' % (attr, str(self)))
|
raise AttributeError('%s in %s' % (attr, str(self)))
|
||||||
return self.attrs[attr]
|
return self.attrs[attr]
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ def parse_objdump(self):
|
|||||||
if not Config.symbol_filter.match(p['symbol']):
|
if not Config.symbol_filter.match(p['symbol']):
|
||||||
continue
|
continue
|
||||||
sym = Symbol(p['symbol'], p['offset'], vername, self)
|
sym = Symbol(p['symbol'], p['offset'], vername, self)
|
||||||
if not self.versions.has_key(vername):
|
if vername not in self.versions:
|
||||||
self.versions[vername] = VersionMap(vername)
|
self.versions[vername] = VersionMap(vername)
|
||||||
self.versions[vername].append(sym)
|
self.versions[vername].append(sym)
|
||||||
if Config.alias_prefixes:
|
if Config.alias_prefixes:
|
||||||
@ -655,7 +655,7 @@ def parse_objdump(self):
|
|||||||
if not p['symbol'].startswith(prefix):
|
if not p['symbol'].startswith(prefix):
|
||||||
continue
|
continue
|
||||||
alias = SymbolAlias(p['symbol'], prefix, p['offset'])
|
alias = SymbolAlias(p['symbol'], prefix, p['offset'])
|
||||||
if self.alias_syms.has_key(alias.name):
|
if alias.name in self.alias_syms:
|
||||||
prevalias = self.alias_syms[alias.name]
|
prevalias = self.alias_syms[alias.name]
|
||||||
if alias.name != prevalias.name or \
|
if alias.name != prevalias.name or \
|
||||||
alias.offset != prevalias.offset:
|
alias.offset != prevalias.offset:
|
||||||
@ -676,7 +676,7 @@ def lookup(sym):
|
|||||||
localnames = self.local_offsetmap[sym.offset]
|
localnames = self.local_offsetmap[sym.offset]
|
||||||
localnames.sort(key=lambda x: -len(x))
|
localnames.sort(key=lambda x: -len(x))
|
||||||
for localname in localnames:
|
for localname in localnames:
|
||||||
if not self.alias_syms.has_key(localname):
|
if localname not in self.alias_syms:
|
||||||
continue
|
continue
|
||||||
alias = self.alias_syms[localname]
|
alias = self.alias_syms[localname]
|
||||||
raw = dwarfdump.offsetmap[alias.offset]
|
raw = dwarfdump.offsetmap[alias.offset]
|
||||||
@ -753,7 +753,7 @@ def add_symbol(self, table, symbol, offsetmap = None):
|
|||||||
return
|
return
|
||||||
table.append(symbol)
|
table.append(symbol)
|
||||||
if offsetmap != None:
|
if offsetmap != None:
|
||||||
if not offsetmap.has_key(offset):
|
if offset not in offsetmap:
|
||||||
offsetmap[offset] = [symbol['symbol']]
|
offsetmap[offset] = [symbol['symbol']]
|
||||||
else:
|
else:
|
||||||
offsetmap[offset].append(symbol['symbol'])
|
offsetmap[offset].append(symbol['symbol'])
|
||||||
@ -921,9 +921,9 @@ def parse_debuginfo(self, line):
|
|||||||
args = self.parse_arg(tag, args)
|
args = self.parse_arg(tag, args)
|
||||||
tag.unit.tags[tag.id] = tag
|
tag.unit.tags[tag.id] = tag
|
||||||
def parse_offset(tag):
|
def parse_offset(tag):
|
||||||
if tag.args.has_key('DW_AT_low_pc'):
|
if 'DW_AT_low_pc' in tag.args:
|
||||||
return int(tag.args['DW_AT_low_pc'], 16)
|
return int(tag.args['DW_AT_low_pc'], 16)
|
||||||
elif tag.args.has_key('DW_AT_location'):
|
elif 'DW_AT_location' in tag.args:
|
||||||
location = tag.args['DW_AT_location']
|
location = tag.args['DW_AT_location']
|
||||||
if location.startswith('DW_OP_addr'):
|
if location.startswith('DW_OP_addr'):
|
||||||
return int(location.replace('DW_OP_addr', ''), 16)
|
return int(location.replace('DW_OP_addr', ''), 16)
|
||||||
@ -931,9 +931,9 @@ def parse_offset(tag):
|
|||||||
offset = parse_offset(tag)
|
offset = parse_offset(tag)
|
||||||
if offset is not None and \
|
if offset is not None and \
|
||||||
(tag.tag not in DwarfdumpParser.skip_tags or \
|
(tag.tag not in DwarfdumpParser.skip_tags or \
|
||||||
(tag.args.has_key('DW_AT_external') and \
|
('DW_AT_external' in tag.args and \
|
||||||
tag.tag in DwarfdumpParser.external_tags)):
|
tag.tag in DwarfdumpParser.external_tags)):
|
||||||
if self.offsetmap.has_key(offset):
|
if offset in self.offsetmap:
|
||||||
raise ValueError("Dwarf dump parse error: " +
|
raise ValueError("Dwarf dump parse error: " +
|
||||||
"symbol is aleady defined at offset 0x%x" % offset)
|
"symbol is aleady defined at offset 0x%x" % offset)
|
||||||
self.offsetmap[offset] = tag
|
self.offsetmap[offset] = tag
|
||||||
|
Loading…
Reference in New Issue
Block a user