Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

Conflicts:

	pynbt/nbt.py
  • Loading branch information...
commit 2bfd3f812715dec755b1446408c681988bfba16e 1 parent 75a33ad
Tyler Kennedy authored July 11, 2012

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. 12  pynbt/nbt.py
12  pynbt/nbt.py
@@ -20,14 +20,14 @@ def _read_utf8(read):
20 20
         """Reads a length-prefixed UTF-8 string."""
21 21
         name_length = read('H', 2)[0]
22 22
         return read(
23  
-            '{}s'.format(name_length),
  23
+            '{0}s'.format(name_length),
24 24
             name_length
25 25
         )[0].decode('utf-8')
26 26
 
27 27
     @staticmethod
28 28
     def _write_utf8(write, value):
29 29
         """Writes a length-prefixed UTF-8 string."""
30  
-        write('h{}s'.format(len(value)), len(value), value)
  30
+        write('h{0}s'.format(len(value)), len(value), value.encode('UTF-8'))
31 31
 
32 32
     @classmethod
33 33
     def read(cls, read, has_name=True):
@@ -71,11 +71,11 @@ def read(cls, read, has_name=True):
71 71
         elif cls is TAG_Byte_Array:
72 72
             # A simple array of (signed) bytes.
73 73
             length = read('i', 4)[0]
74  
-            return cls(read('{}b'.format(length), length), name=name)
  74
+            return cls(read('{0}b'.format(length), length), name=name)
75 75
         elif cls is TAG_Int_Array:
76 76
             # A simple array of (signed) 4-byte integers.
77 77
             length = read('i', 4)[0]
78  
-            return cls(read('{}i'.format(length), length * 4), name=name)
  78
+            return cls(read('{0}i'.format(length), length * 4), name=name)
79 79
         elif cls is TAG_Byte:
80 80
             # A single (signed) byte.
81 81
             return cls(read('b', 1)[0], name=name)
@@ -121,10 +121,10 @@ def write(self, write):
121 121
             self._write_utf8(write, self.value)
122 122
         elif isinstance(self, TAG_Int_Array):
123 123
             l = len(self.value)
124  
-            write('i{}i'.format(l), l, *self.value)
  124
+            write('i{0}i'.format(l), l, *self.value)
125 125
         elif isinstance(self, TAG_Byte_Array):
126 126
             l = len(self.value)
127  
-            write('i{}b'.format(l), l, *self.value)
  127
+            write('i{0}b'.format(l), l, *self.value)
128 128
         elif isinstance(self, TAG_Byte):
129 129
             write('b', self.value)
130 130
         elif isinstance(self, TAG_Short):

0 notes on commit 2bfd3f8

Please sign in to comment.
Something went wrong with that request. Please try again.