Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in
non-pydebug builds. Several extension modules now compile cleanly when
assert()s are enabled in standard builds (-DDEBUG flag).
diff --git a/Misc/NEWS b/Misc/NEWS
index e4fd504..41126a6 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -4293,6 +4293,10 @@
Extension Modules
-----------------
+- Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in
+ non-pydebug builds. Several extension modules now compile cleanly when
+ assert()s are enabled in standard builds (-DDEBUG flag).
+
- Issue #13840: The error message produced by ctypes.create_string_buffer
when given a Unicode string has been fixed.
diff --git a/Modules/_json.c b/Modules/_json.c
index 5b42f6f..db45c28 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -246,7 +246,9 @@
}
}
output[chars++] = '"';
+#ifdef Py_DEBUG
assert(_PyUnicode_CheckConsistency(rval, 1));
+#endif
return rval;
}
diff --git a/Modules/md5module.c b/Modules/md5module.c
index e2681a8..12e187c 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -399,7 +399,9 @@
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
+#ifdef Py_DEBUG
assert(_PyUnicode_CheckConsistency(retval, 1));
+#endif
return retval;
}
diff --git a/Modules/sha1module.c b/Modules/sha1module.c
index a733c4b..09b87ef 100644
--- a/Modules/sha1module.c
+++ b/Modules/sha1module.c
@@ -376,7 +376,9 @@
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
+#ifdef Py_DEBUG
assert(_PyUnicode_CheckConsistency(retval, 1));
+#endif
return retval;
}
diff --git a/Modules/sha256module.c b/Modules/sha256module.c
index 76d91af..9f6b416 100644
--- a/Modules/sha256module.c
+++ b/Modules/sha256module.c
@@ -466,7 +466,9 @@
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
+#ifdef Py_DEBUG
assert(_PyUnicode_CheckConsistency(retval, 1));
+#endif
return retval;
}
diff --git a/Modules/sha512module.c b/Modules/sha512module.c
index 88f8a64..5536fd5 100644
--- a/Modules/sha512module.c
+++ b/Modules/sha512module.c
@@ -532,7 +532,9 @@
c = (digest[i] & 0xf);
hex_digest[j++] = Py_hexdigits[c];
}
+#ifdef Py_DEBUG
assert(_PyUnicode_CheckConsistency(retval, 1));
+#endif
return retval;
}