[pypy-svn] r15318 - in pypy/dist/pypy/interpreter/pyparser: . test

pedronis at codespeak.net pedronis at codespeak.net
Fri Jul 29 03:27:36 CEST 2005


Author: pedronis
Date: Fri Jul 29 03:27:33 2005
New Revision: 15318

Modified:
   pypy/dist/pypy/interpreter/pyparser/parsestring.py
   pypy/dist/pypy/interpreter/pyparser/test/test_parsestring.py
Log:
new test, doesn't work right now failing somewhere from app_codecs. parsestr itself is correct because
encoding through cheating  passes the test

the problem need to be tracked and fixed



Modified: pypy/dist/pypy/interpreter/pyparser/parsestring.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/parsestring.py	(original)
+++ pypy/dist/pypy/interpreter/pyparser/parsestring.py	Fri Jul 29 03:27:33 2005
@@ -87,6 +87,7 @@
     if rawmode or '\\' not in s[ps:]:
         if need_encoding:
             w_u = PyUnicode_DecodeUTF8(space, space.wrap(substr))
+            #w_v = space.wrap(space.unwrap(w_u).encode(encoding)) this works
             w_v = PyUnicode_AsEncodedString(space, w_u, space.wrap(encoding))
             return w_v
         else:

Modified: pypy/dist/pypy/interpreter/pyparser/test/test_parsestring.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_parsestring.py	(original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_parsestring.py	Fri Jul 29 03:27:33 2005
@@ -1,4 +1,5 @@
 from pypy.interpreter.pyparser import parsestring
+import py
 
 class TestParsetring:
     def test_simple(self):
@@ -40,3 +41,13 @@
         w_ret = parsestring.parsestr(self.space, 'koi8-u', s)
         ret = space.unwrap(w_ret)
         assert ret == eval("# -*- coding: koi8-u -*-\nu'\x81'") 
+
+    def test_simple_enc_roundtrip(self):
+        py.test.skip("crashes in app_codecs, but when cheating using .encode at interp-level passes?!")
+        space = self.space
+        s = "'\x81'"
+        s = s.decode("koi8-u").encode("utf8")
+        w_ret = parsestring.parsestr(self.space, 'koi8-u', s)
+        ret = space.unwrap(w_ret)
+        assert ret == eval("# -*- coding: koi8-u -*-\n'\x81'") 
+



More information about the Pypy-commit mailing list