Philip Jenvey avatar Philip Jenvey committed 0dacceb

cpython issue3574: fix latin1 decoding, it's no longer special cased

Comments (0)

Files changed (2)

pypy/interpreter/astcompiler/test/test_astbuilder.py

         s = ast_from_node(space, tree, info).body[0].value
         assert isinstance(s, ast.Str)
         assert space.eq_w(s.s, space.wrap(japan))
+
+    def test_issue3574(self):
+        space = self.space
+        source = u'# coding: Latin-1\nu = "Ç"\n'
+        info = pyparse.CompileInfo("<test>", "exec")
+        tree = self.parser.parse_source(source.encode("Latin-1"), info)
+        assert info.encoding == "iso-8859-1"
+        s = ast_from_node(space, tree, info).body[0].value
+        assert isinstance(s, ast.Str)
+        assert space.eq_w(s.s, space.wrap(u'Ç'))
  
     def test_string_bug(self):
         py.test.py3k_skip('fixme')

pypy/interpreter/pyparser/parsestring.py

 def parsestr(space, encoding, s):
     """Parses a string or unicode literal, and return a wrapped value.
 
-    If encoding=iso8859-1, the source string is also in this encoding.
     If encoding=None, the source string is ascii only.
     In other cases, the source string is in utf-8 encoding.
 
         q -= 2
 
     if unicode_literal and not rawmode: # XXX Py_UnicodeFlag is ignored for now
-        if encoding is None or encoding == "iso-8859-1":
-            # 'unicode_escape' expects latin-1 bytes, string is ready.
+        if encoding is None:
             buf = s
             bufp = ps
             bufq = q
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.