Check newly created consistency using _PyUnicode_CheckConsistency(str, 1)

* In debug mode, fill the string data with invalid characters
 * Simplify also reference counting in PyCodec_BackslashReplaceErrors()
   and PyCodec_XMLCharRefReplaceError()
This commit is contained in:
Victor Stinner 2012-04-27 13:55:39 +02:00
parent 990eff0776
commit 8f825060f1
10 changed files with 31 additions and 14 deletions

View file

@ -246,6 +246,7 @@ ascii_escape_unicode(PyObject *pystr)
}
}
output[chars++] = '"';
assert(_PyUnicode_CheckConsistency(rval, 1));
return rval;
}

View file

@ -397,6 +397,7 @@ MD5_hexdigest(MD5object *self, PyObject *unused)
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
assert(_PyUnicode_CheckConsistency(retval, 1));
return retval;
}

View file

@ -373,6 +373,7 @@ SHA1_hexdigest(SHA1object *self, PyObject *unused)
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
assert(_PyUnicode_CheckConsistency(retval, 1));
return retval;
}

View file

@ -466,6 +466,7 @@ SHA256_hexdigest(SHAobject *self, PyObject *unused)
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
assert(_PyUnicode_CheckConsistency(retval, 1));
return retval;
}

View file

@ -532,6 +532,7 @@ SHA512_hexdigest(SHAobject *self, PyObject *unused)
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
assert(_PyUnicode_CheckConsistency(retval, 1));
return retval;
}