#13406: fix more deprecation warnings and move the deprecation of unicode-internal earlier in the code.
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 4cd5c23..7818f9a 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -677,6 +677,11 @@
const char *data;
Py_ssize_t len, size;
+ if (PyErr_WarnEx(PyExc_DeprecationWarning,
+ "unicode_internal codec has been deprecated",
+ 1))
+ return NULL;
+
if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
&obj, &errors))
return NULL;
@@ -687,11 +692,6 @@
if (PyUnicode_READY(obj) < 0)
return NULL;
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "unicode_internal codec has been deprecated",
- 1))
- return NULL;
-
u = PyUnicode_AsUnicodeAndSize(obj, &len);
if (u == NULL)
return NULL;