bpo-36346: array: Don't use deprecated APIs (GH-19653)
* Py_UNICODE -> wchar_t
* Py_UNICODE -> unicode in Argument Clinic
* PyUnicode_AsUnicode -> PyUnicode_AsWideCharString
* Don't use "u#" format.
Co-authored-by: Victor Stinner <vstinner@python.org>
diff --git a/Modules/clinic/arraymodule.c.h b/Modules/clinic/arraymodule.c.h
index e1f4b03..b9245ca 100644
--- a/Modules/clinic/arraymodule.c.h
+++ b/Modules/clinic/arraymodule.c.h
@@ -380,20 +380,23 @@
{"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
static PyObject *
-array_array_fromunicode_impl(arrayobject *self, const Py_UNICODE *ustr,
- Py_ssize_clean_t ustr_length);
+array_array_fromunicode_impl(arrayobject *self, PyObject *ustr);
static PyObject *
array_array_fromunicode(arrayobject *self, PyObject *arg)
{
PyObject *return_value = NULL;
- const Py_UNICODE *ustr;
- Py_ssize_clean_t ustr_length;
+ PyObject *ustr;
- if (!PyArg_Parse(arg, "u#:fromunicode", &ustr, &ustr_length)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("fromunicode", "argument", "str", arg);
goto exit;
}
- return_value = array_array_fromunicode_impl(self, ustr, ustr_length);
+ if (PyUnicode_READY(arg) == -1) {
+ goto exit;
+ }
+ ustr = arg;
+ return_value = array_array_fromunicode_impl(self, ustr);
exit:
return return_value;
@@ -531,4 +534,4 @@
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=f649fc0bc9f6b13a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9f70748dd3bc532f input=a9049054013a1b77]*/