[pypy-svn] r50265 - pypy/branch/ghop-ropes-classes/pypy/rlib

vinogradov at codespeak.net vinogradov at codespeak.net
Wed Jan 2 17:48:21 CET 2008


Author: vinogradov
Date: Wed Jan  2 17:48:21 2008
New Revision: 50265

Modified:
   pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
Log:
Update encode and decode functions

Modified: pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
==============================================================================
--- pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py	(original)
+++ pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py	Wed Jan  2 17:48:21 2008
@@ -63,6 +63,11 @@
     def __iter__(self):
         return RopeStringIterator(self._node)
     
+    def encode(self, encoding, errors='strict'):
+        s = self._node.flatten_string()
+        result = s.encode(encoding, errors)
+        return RopeUnicode(result)
+    
     def decode(self, codepage, errors='strict'):
         s = self._node.flatten_string()
         result = s.decode(codepage, errors)
@@ -104,5 +109,10 @@
         result = s.encode(encoding, errors)
         return RopeString(result)
     
+    def decode(self, codepage, errors = 'strict'):
+        s = self._node.flatten_unicode()
+        result = s.decode(codepage, errors)
+        return RopeUnicode(result)
+    
     def getchar(self,index):
         return self._node.getunichar(index)



More information about the Pypy-commit mailing list