Decodes a syncsafe integer

def decode(data):
        "Decodes a syncsafe integer"
        value = 0
        for b in data:
            if b > 127:  # iTunes bug
                raise ValueError("Invalid syncsafe integer")
            value <<= 7
            value += b
        return value