Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Py2.6 compatibility fix (can't use {} shortcut until 2.7)

Conflicts:

	pynbt/nbt.py
  • Loading branch information...
commit 2bfd3f812715dec755b1446408c681988bfba16e 1 parent 75a33ad
@TkTech authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 pynbt/nbt.py
View
12 pynbt/nbt.py
@@ -20,14 +20,14 @@ def _read_utf8(read):
"""Reads a length-prefixed UTF-8 string."""
name_length = read('H', 2)[0]
return read(
- '{}s'.format(name_length),
+ '{0}s'.format(name_length),
name_length
)[0].decode('utf-8')
@staticmethod
def _write_utf8(write, value):
"""Writes a length-prefixed UTF-8 string."""
- write('h{}s'.format(len(value)), len(value), value)
+ write('h{0}s'.format(len(value)), len(value), value.encode('UTF-8'))
@classmethod
def read(cls, read, has_name=True):
@@ -71,11 +71,11 @@ def read(cls, read, has_name=True):
elif cls is TAG_Byte_Array:
# A simple array of (signed) bytes.
length = read('i', 4)[0]
- return cls(read('{}b'.format(length), length), name=name)
+ return cls(read('{0}b'.format(length), length), name=name)
elif cls is TAG_Int_Array:
# A simple array of (signed) 4-byte integers.
length = read('i', 4)[0]
- return cls(read('{}i'.format(length), length * 4), name=name)
+ return cls(read('{0}i'.format(length), length * 4), name=name)
elif cls is TAG_Byte:
# A single (signed) byte.
return cls(read('b', 1)[0], name=name)
@@ -121,10 +121,10 @@ def write(self, write):
self._write_utf8(write, self.value)
elif isinstance(self, TAG_Int_Array):
l = len(self.value)
- write('i{}i'.format(l), l, *self.value)
+ write('i{0}i'.format(l), l, *self.value)
elif isinstance(self, TAG_Byte_Array):
l = len(self.value)
- write('i{}b'.format(l), l, *self.value)
+ write('i{0}b'.format(l), l, *self.value)
elif isinstance(self, TAG_Byte):
write('b', self.value)
elif isinstance(self, TAG_Short):
Please sign in to comment.
Something went wrong with that request. Please try again.