python json_encode throws KeyError exception
- by MattM
In a unit test case that I am running, I get a KeyError exception on the 4th json object in the json text below. I went through the sub-objects and found that it was the "cpuid" object that is the offending object, but I am completely at a loss as to what is wrong with the formatting.
response = self.app.post(
'/machinestats',
params=dict(record=self.json_encode([
{"type": "crash", "instance_id": "xxx",
"version": "0.2.0", "build_id": "unknown",
"crash_text": "Gah!"},
{"type": "machine_info", "machine_info": "I'm awesome.",
"version": "0.2.0", "build_id": "unknown",
"instance_id": "yyy"},
{"machine_info": "Soup", "crash_text": "boom!",
"version": "0.2.0", "build_id": "unknown",
"instance_id": "zzz", "type": "crash"},
{"build_id" : "unknown", "cpu_brand" : "intel",
"cpu_count" : 4,
"cpuid": {
"00000000":
{"eax" :123,"ebx" :456,
"ecx" :789,"edx" :321},
"00000001":
{"eax" :123,"ebx" :456,
"ecx" :789,"edx" :321}},
"driver_installed" : True,
"instance_id" : "yyy",
"version" : "0.2.0",
"machine_info" : "I'm awesome.",
"os_version" : "linux",
"physical_memory_mib" : 1024,
"product_loaded" : True,
"type" : "machine_info",
"virtualization_advertised" : True}
])))