Author: Yusuke Tsutsumi <yusu...@tsutsumi.io>
Branch: py3.6
Changeset: r94696:f9930d8ca5da
Date: 2018-05-13 21:41 -0700
http://bitbucket.org/pypy/pypy/changeset/f9930d8ca5da/

Log:    Resolving failing deprecation tests by moving the warning code

        Moving the warning code for unicode errors higher up the chain,
        thereby ensuring the warnings are emitted in those calls.

diff --git a/lib-python/3/test/test_codecs.py b/lib-python/3/test/test_codecs.py
--- a/lib-python/3/test/test_codecs.py
+++ b/lib-python/3/test/test_codecs.py
@@ -2468,7 +2468,8 @@
                 with self.assertWarns(DeprecationWarning):
                     check(b"\\" + b, "\\" + chr(i))
             if b.upper() not in b'UN':
-                with self.assertWarns(DeprecationWarning):
+                with self.assertWarns(DeprecationWarning,
+                                      msg="character {} did not raise an 
exception".format(i)):
                     check(b"\\" + b.upper(), "\\" + chr(i-32))
         with self.assertWarns(DeprecationWarning):
             check(br"\8", "\\8")
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
@@ -117,12 +117,6 @@
     v, first_escape_error_char = PyString_DecodeEscape(
         space, substr, 'strict', encoding)
 
-    if first_escape_error_char != '':
-        space.warn(
-            space.newtext("invalid escape sequence '\\%s'"
-                          % first_escape_error_char),
-            space.w_DeprecationWarning)
-
     return space.newbytes(v)
 
 def decode_unicode_utf8(space, s, ps, q):
@@ -252,6 +246,13 @@
             # an arbitry number of unescaped UTF-8 bytes may follow.
 
     buf = builder.build()
+
+    if first_escape_error_char != '':
+        space.warn(
+            space.newtext("invalid escape sequence '\\%s'"
+                          % first_escape_error_char),
+            space.w_DeprecationWarning)
+
     return buf, first_escape_error_char
 
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to