[pypy-commit] pypy py3k: cpython issue3574: fix latin1 decoding, it's no longer special cased
pjenvey
noreply at buildbot.pypy.org
Tue Jan 29 02:09:18 CET 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r60645:0dacceb8afd5
Date: 2013-01-28 17:07 -0800
http://bitbucket.org/pypy/pypy/changeset/0dacceb8afd5/
Log: cpython issue3574: fix latin1 decoding, it's no longer special cased
diff --git a/pypy/interpreter/astcompiler/test/test_astbuilder.py b/pypy/interpreter/astcompiler/test/test_astbuilder.py
--- a/pypy/interpreter/astcompiler/test/test_astbuilder.py
+++ b/pypy/interpreter/astcompiler/test/test_astbuilder.py
@@ -1134,6 +1134,16 @@
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')
diff --git a/pypy/interpreter/pyparser/parsestring.py b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -5,7 +5,6 @@
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.
@@ -49,8 +48,7 @@
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
More information about the pypy-commit
mailing list