Commits

Ronald Oussoren committed 126216e

Merged revisions 2595 via svnmerge from
https://svn.red-bean.com/pyobjc/trunk/pyobjc

........
r2595 | ronaldoussoren | 2010-10-05 14:09:52 +0200 (Tue, 05 Oct 2010) | 2 lines

Avoid exceptions when doing str(anNSData).
........

  • Participants
  • Parent commits 8cd9deb
  • Branches pyobjc-2.3.x

Comments (0)

Files changed (1)

File pyobjc-core/Lib/objc/_convenience.py

     except TypeError:
         return buff[:][item]
 
+
+if sys.version_info[:2] <= (2,6):
+    def NSData__str__(self):
+        return self.bytes()[:]
+
+elif sys.version_info[0] == 2:
+    def NSData__str__(self):
+        return str(self.bytes().tobytes())
+
+else:
+    def NSData__str__(self):
+        return str(self.bytes().tobytes())
+
+
 CLASS_METHODS['NSData'] = (
-    ('__str__', lambda self: self.bytes()[:]),
+    ('__str__', NSData__str__),
     ('__getitem__', NSData__getitem__),
     ('__getslice__', NSData__getslice__),
 )