Closed Bug 1329993 Opened 7 years ago Closed 7 years ago

heka_message_parser.py _lazyjson() breaks dict.__cmp__

Categories

(Data Platform and Tools :: General, defect, P2)

defect
Points:
1

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: spenrose, Unassigned)

References

Details

_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.
please add priority and effort Mauro
Flags: needinfo?(mdoglio)
Points: --- → 1
Flags: needinfo?(mdoglio)
Priority: -- → P2
Component: Metrics: Pipeline → Telemetry APIs for Analysis
Product: Cloud Services → Data Platform and Tools
See Also: → 1376028
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Component: Telemetry APIs for Analysis → General
You need to log in before you can comment on or make changes to this bug.