Author: Matti Picus <[email protected]>
Branch: py3.6
Changeset: r97587:e0c3eceb2db4
Date: 2019-09-22 00:45 +0300
http://bitbucket.org/pypy/pypy/changeset/e0c3eceb2db4/

Log:    back out b2dd9b388196 and reinstate abe60bf6dc7b

diff --git a/pypy/interpreter/pyparser/test/apptest_parsestring.py 
b/pypy/interpreter/pyparser/test/apptest_parsestring.py
--- a/pypy/interpreter/pyparser/test/apptest_parsestring.py
+++ b/pypy/interpreter/pyparser/test/apptest_parsestring.py
@@ -8,3 +8,11 @@
             eval("b'''\n\\z'''")
     assert not w
     assert excinfo.value.filename == '<string>'
+
+def test_str_invalid_escape():
+    with warnings.catch_warnings(record=True) as w:
+        warnings.simplefilter('error', category=DeprecationWarning)
+        with raises(SyntaxError) as excinfo:
+            eval("'''\n\\z'''")
+    assert not w
+    assert excinfo.value.filename == '<string>'
diff --git a/pypy/interpreter/unicodehelper.py 
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -130,6 +130,15 @@
         final=True,
         errorhandler=state.decode_error_handler,
         ud_handler=unicodedata_handler)
+    if first_escape_error_char is not None:
+        msg = "invalid escape sequence '%s'"
+        try:
+            space.warn(space.newtext(msg % first_escape_error_char), 
space.w_DeprecationWarning)
+        except OperationError as e:
+            if e.match(space, space.w_DeprecationWarning):
+                raise oefmt(space.w_SyntaxError, msg, first_escape_error_char)
+            else:
+                raise
     return s, ulen, blen
 
 def decode_raw_unicode_escape(space, string):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to