Author: Tomasz Dziopa <[email protected]>
Branch: py3.6
Changeset: r94409:d3ffc4376fe9
Date: 2018-04-22 09:41 +0100
http://bitbucket.org/pypy/pypy/changeset/d3ffc4376fe9/

Log:    (tdziopa) fix warnings for PyString_DecodeEscape

        Recent PR introduced a bug with undefined variable ch being accessed
        when raising DeprecationWarning on errorneous escaping. This PR
        fixes that issue and changes the names of variables to better
        reflect their contents (first_escape_error_position ->
        first_escape_error_char)

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
@@ -114,11 +114,11 @@
             v = unicodehelper.decode_utf8(space, substr)
             return space.newunicode(v)
 
-    v, first_escape_error_position = PyString_DecodeEscape(
+    v, first_escape_error_char = PyString_DecodeEscape(
         space, substr, 'strict', encoding)
 
-    if first_escape_error_position is not None:
-        space.warn("invalid excape sequence '\\%c'" % ch,
+    if first_escape_error_char is not None:
+        space.warn("invalid excape sequence '\\%c'" % first_escape_error_char,
             space.w_DeprecationWarning)
 
     return space.newbytes(v)
@@ -164,7 +164,7 @@
     builder = StringBuilder(len(s))
     ps = 0
     end = len(s)
-    first_escape_error_position = None
+    first_escape_error_char = None
     while ps < end:
         if s[ps] != '\\':
             # note that the C code has a label here.
@@ -244,13 +244,13 @@
             builder.append('\\')
             ps -= 1
             assert ps >= 0
-            if first_escape_error_position is None:
-                first_escape_error_position = ps
+            if first_escape_error_char is None:
+                first_escape_error_char = ch
             continue
             # an arbitry number of unescaped UTF-8 bytes may follow.
 
     buf = builder.build()
-    return buf, first_escape_error_position
+    return buf, first_escape_error_char
 
 
 def isxdigit(ch):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to