From 111be952d46ee8cc388cfd8061d733aea3cd02d0 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Thu, 7 Apr 2011 13:00:28 -1000 Subject: [PATCH] create an NBTFormatError and raise it where appropriate instead of IOError --- nbt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nbt.py b/nbt.py index d4cc63f..59f7783 100644 --- a/nbt.py +++ b/nbt.py @@ -28,6 +28,8 @@ from contextlib import closing from numpy import array, zeros, uint8, fromstring TAGfmt = ">b" +class NBTFormatError(RuntimeError): pass + class TAG_Value(object): """Simple values. Subclasses override fmt to change the type and size. Subclasses may set dataType instead of overriding setValue for automatic data type coercion""" @@ -433,12 +435,12 @@ def load(filename="", buf=None): data = buf; #if buf != None: data = buf if not len(buf): - raise IOError, "Asked to load root tag of zero length" + raise NBTFormatError, "Asked to load root tag of zero length" data_cursor = 0; tag_type = data[data_cursor]; if tag_type != 10: - raise IOError, 'Not an NBT file with a root TAG_Compound (found {0})'.format(tag_type); + raise NBTFormatError, 'Not an NBT file with a root TAG_Compound (found {0})'.format(tag_type); data_cursor += 1; data_cursor, tag = load_named(data, data_cursor, tag_type)