summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-12-09 13:09:14 (GMT)
committerGitHub <noreply@github.com>2019-12-09 13:09:14 (GMT)
commit0131aba5ae20d704b972ecd2ef0fc6c9e370a1b3 (patch)
tree2b0d2377452d9be8d09b46f38fffbceb4692110d /Modules
parenta1838ec2592e5082c75c77888f2a7a3eb21133e5 (diff)
downloadcpython-0131aba5ae20d704b972ecd2ef0fc6c9e370a1b3.zip
cpython-0131aba5ae20d704b972ecd2ef0fc6c9e370a1b3.tar.gz
cpython-0131aba5ae20d704b972ecd2ef0fc6c9e370a1b3.tar.bz2
bpo-38916: array.array: remove fromstring() and tostring() (GH-17487)
array.array: Remove tostring() and fromstring() methods. They were aliases to tobytes() and frombytes(), deprecated since Python 3.2.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/arraymodule.c41
-rw-r--r--Modules/clinic/arraymodule.c.h70
2 files changed, 1 insertions, 110 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 1ceba9e..edb56ab 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1624,27 +1624,6 @@ frombytes(arrayobject *self, Py_buffer *buffer)
}
/*[clinic input]
-array.array.fromstring
-
- buffer: Py_buffer(accept={str, buffer})
- /
-
-Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).
-
-This method is deprecated. Use frombytes instead.
-[clinic start generated code]*/
-
-static PyObject *
-array_array_fromstring_impl(arrayobject *self, Py_buffer *buffer)
-/*[clinic end generated code: output=31c4baa779df84ce input=a3341a512e11d773]*/
-{
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "fromstring() is deprecated. Use frombytes() instead.", 2) != 0)
- return NULL;
- return frombytes(self, buffer);
-}
-
-/*[clinic input]
array.array.frombytes
buffer: Py_buffer
@@ -1679,24 +1658,6 @@ array_array_tobytes_impl(arrayobject *self)
}
/*[clinic input]
-array.array.tostring
-
-Convert the array to an array of machine values and return the bytes representation.
-
-This method is deprecated. Use tobytes instead.
-[clinic start generated code]*/
-
-static PyObject *
-array_array_tostring_impl(arrayobject *self)
-/*[clinic end generated code: output=7d6bd92745a2c8f3 input=b6c0ddee7b30457e]*/
-{
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "tostring() is deprecated. Use tobytes() instead.", 2) != 0)
- return NULL;
- return array_array_tobytes_impl(self);
-}
-
-/*[clinic input]
array.array.fromunicode
ustr: Py_UNICODE(zeroes=True)
@@ -2283,7 +2244,6 @@ static PyMethodDef array_methods[] = {
ARRAY_ARRAY_EXTEND_METHODDEF
ARRAY_ARRAY_FROMFILE_METHODDEF
ARRAY_ARRAY_FROMLIST_METHODDEF
- ARRAY_ARRAY_FROMSTRING_METHODDEF
ARRAY_ARRAY_FROMBYTES_METHODDEF
ARRAY_ARRAY_FROMUNICODE_METHODDEF
ARRAY_ARRAY_INDEX_METHODDEF
@@ -2294,7 +2254,6 @@ static PyMethodDef array_methods[] = {
ARRAY_ARRAY_REVERSE_METHODDEF
ARRAY_ARRAY_TOFILE_METHODDEF
ARRAY_ARRAY_TOLIST_METHODDEF
- ARRAY_ARRAY_TOSTRING_METHODDEF
ARRAY_ARRAY_TOBYTES_METHODDEF
ARRAY_ARRAY_TOUNICODE_METHODDEF
ARRAY_ARRAY___SIZEOF___METHODDEF
diff --git a/Modules/clinic/arraymodule.c.h b/Modules/clinic/arraymodule.c.h
index 33f82d4..e1f4b03 100644
--- a/Modules/clinic/arraymodule.c.h
+++ b/Modules/clinic/arraymodule.c.h
@@ -312,54 +312,6 @@ array_array_tolist(arrayobject *self, PyObject *Py_UNUSED(ignored))
return array_array_tolist_impl(self);
}
-PyDoc_STRVAR(array_array_fromstring__doc__,
-"fromstring($self, buffer, /)\n"
-"--\n"
-"\n"
-"Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).\n"
-"\n"
-"This method is deprecated. Use frombytes instead.");
-
-#define ARRAY_ARRAY_FROMSTRING_METHODDEF \
- {"fromstring", (PyCFunction)array_array_fromstring, METH_O, array_array_fromstring__doc__},
-
-static PyObject *
-array_array_fromstring_impl(arrayobject *self, Py_buffer *buffer);
-
-static PyObject *
-array_array_fromstring(arrayobject *self, PyObject *arg)
-{
- PyObject *return_value = NULL;
- Py_buffer buffer = {NULL, NULL};
-
- if (PyUnicode_Check(arg)) {
- Py_ssize_t len;
- const char *ptr = PyUnicode_AsUTF8AndSize(arg, &len);
- if (ptr == NULL) {
- goto exit;
- }
- PyBuffer_FillInfo(&buffer, arg, (void *)ptr, len, 1, 0);
- }
- else { /* any bytes-like object */
- if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- _PyArg_BadArgument("fromstring", "argument", "contiguous buffer", arg);
- goto exit;
- }
- }
- return_value = array_array_fromstring_impl(self, &buffer);
-
-exit:
- /* Cleanup for buffer */
- if (buffer.obj) {
- PyBuffer_Release(&buffer);
- }
-
- return return_value;
-}
-
PyDoc_STRVAR(array_array_frombytes__doc__,
"frombytes($self, buffer, /)\n"
"--\n"
@@ -414,26 +366,6 @@ array_array_tobytes(arrayobject *self, PyObject *Py_UNUSED(ignored))
return array_array_tobytes_impl(self);
}
-PyDoc_STRVAR(array_array_tostring__doc__,
-"tostring($self, /)\n"
-"--\n"
-"\n"
-"Convert the array to an array of machine values and return the bytes representation.\n"
-"\n"
-"This method is deprecated. Use tobytes instead.");
-
-#define ARRAY_ARRAY_TOSTRING_METHODDEF \
- {"tostring", (PyCFunction)array_array_tostring, METH_NOARGS, array_array_tostring__doc__},
-
-static PyObject *
-array_array_tostring_impl(arrayobject *self);
-
-static PyObject *
-array_array_tostring(arrayobject *self, PyObject *Py_UNUSED(ignored))
-{
- return array_array_tostring_impl(self);
-}
-
PyDoc_STRVAR(array_array_fromunicode__doc__,
"fromunicode($self, ustr, /)\n"
"--\n"
@@ -599,4 +531,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=6aa421571e2c0756 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f649fc0bc9f6b13a input=a9049054013a1b77]*/