From 06174e7c2a22fe31812bf0e43e00105e01e49718 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 27 Jan 2013 17:14:55 -0600 Subject: py26 fix for RomStr.load_labels (json) original-commit-id: 9e9c37f5771c989630fa670aaafdc2ab1fdf1edf --- romstr.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'romstr.py') diff --git a/romstr.py b/romstr.py index 2e4db8b..d2eea44 100644 --- a/romstr.py +++ b/romstr.py @@ -4,9 +4,13 @@ import sys import os import time import datetime -import json from ctypes import c_int8 from copy import copy +import json + +# New versions of json don't have read anymore. +if not hasattr(json, "read"): + json.read = json.loads from labels import ( get_label_from_line, @@ -100,7 +104,7 @@ class RomStr(str): file_handler.close() # load the labels from the file - self.labels = json.loads(open(filename, "r").read()) + self.labels = json.read(open(filename, "r").read()) def get_address_for(self, label): """ Returns the address of a label. This is slow and could be improved -- cgit v1.2.3