Author: Antonio Cuni <anto.c...@gmail.com>
Branch: py3k
Changeset: r56535:24780967f269
Date: 2012-08-02 17:15 +0200
http://bitbucket.org/pypy/pypy/changeset/24780967f269/

Log:    fix -A support when the source code contains unicode chars. Fix
        test_unicode_keywords to pass on CPython3 (still fails on pypy)

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -205,7 +205,11 @@
 def run_with_python(python, target):
     if python is None:
         py.test.skip("Cannot find the default python3 interpreter to run with 
-A")
-    helpers = r"""if 1:
+    # we assume that the source of target is in utf-8. Unfortunately, we don't
+    # have any easy/standard way to determine from here the original encoding
+    # of the source file
+    helpers = r"""# -*- encoding: utf-8 -*-
+if 1:
     import sys
     def skip(message):
         print(message)
@@ -232,7 +236,9 @@
 """
     source = py.code.Source(target)[1:].deindent()
     pyfile = udir.join('src.py')
-    pyfile.write(helpers + str(source))
+    source = helpers + str(source)
+    with pyfile.open('w') as f:
+        f.write(source)
     res, stdout, stderr = runsubprocess.run_subprocess(
         python, [str(pyfile)])
     print source
diff --git a/pypy/interpreter/test/test_argument.py 
b/pypy/interpreter/test/test_argument.py
--- a/pypy/interpreter/test/test_argument.py
+++ b/pypy/interpreter/test/test_argument.py
@@ -653,7 +653,7 @@
         # "f() got an unexpected keyword argument '&#252;'"
         def f(x): pass
         e = raises(TypeError, "f(**{'&#252;' : 19})")
-        assert "?" in str(e.value)
+        assert "'&#252;'" in str(e.value)
         """
 
 def make_arguments_for_translation(space, args_w, keywords_w={},
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to