[pypy-commit] pypy py3.6: Resolving failing deprecation tests by moving the warning code
Yusuke Tsutsumi
pypy.commits at gmail.com
Tue May 29 02:08:24 EDT 2018
Author: Yusuke Tsutsumi <yusuket at 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
More information about the pypy-commit
mailing list