heka_message_parser.py _lazyjson() breaks dict.__cmp__

RESOLVED FIXED

Status

P2
normal
RESOLVED FIXED
2 years ago
a year ago

People

(Reporter: spenrose, Unassigned)

Tracking

Details

(Reporter)

Description

2 years ago
_wrap() breaks comparison of Python dictionaries to non-dictionary objects. Working with pings loaded from JSON, you need to compare dictionaries a lot:

def descend(d):
.   path = ['environment', 'settings', 'defaultSearchEngineData', 'origin']
.   while path:
.   key = path.pop(0)
.   d = d.get(key)
.   blowup = d == 'some string'

This fails due to _lazyjson()'s invocation of getattr():

File "/home/hadoop/anaconda2/lib/python2.7/site-packages/moztelemetry/heka_message_parser.py", line 92, in _wrap
return method(*args[1:], **kwargs)
TypeError: dict.cmp(x,y) requires y to be a 'dict', not a 'str'

Workaround is to test for isinstance(dict, other) before comparing, which may not be obvious to your average bear.
Blocks: 1255748

Comment 1

2 years ago
please add priority and effort Mauro
Flags: needinfo?(mdoglio)
Points: --- → 1
Flags: needinfo?(mdoglio)
Priority: -- → P2

Updated

2 years ago
Component: Metrics: Pipeline → Telemetry APIs for Analysis
Product: Cloud Services → Data Platform and Tools
See Also: → bug 1376028
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.