Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indent_style = space
indent_size = 4

[*.rst]
indent_size = 3
indent_size = 2

[*.{js,yml,yaml}]
indent_size = 2
4 changes: 0 additions & 4 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions Doc/deprecations/c-api-pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ Pending removal in Python 3.15
:c:func:`PyWeakref_GetRef` on Python 3.12 and older.
* :c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro:
Use :c:type:`wchar_t` instead.
* :c:func:`!PyUnicode_AsDecodedObject`:
Use :c:func:`PyCodec_Decode` instead.
* :c:func:`!PyUnicode_AsDecodedUnicode`:
Use :c:func:`PyCodec_Decode` instead; Note that some codecs (for example, "base64")
may return a type other than :class:`str`, such as :class:`bytes`.
* :c:func:`!PyUnicode_AsEncodedObject`:
Use :c:func:`PyCodec_Encode` instead.
* :c:func:`!PyUnicode_AsEncodedUnicode`:
Use :c:func:`PyCodec_Encode` instead; Note that some codecs (for example, "base64")
may return a type other than :class:`bytes`, such as :class:`str`.
* Python initialization functions, deprecated in Python 3.13:

* :c:func:`Py_GetPath`:
Expand Down
15 changes: 15 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,20 @@ Deprecated C APIs
Removed C APIs
--------------

*

* :c:func:`!PyUnicode_AsDecodedObject`:
Use :c:func:`PyCodec_Decode` instead.
* :c:func:`!PyUnicode_AsDecodedUnicode`:
Use :c:func:`PyCodec_Decode` instead; Note that some codecs (for example, "base64")
may return a type other than :class:`str`, such as :class:`bytes`.
* :c:func:`!PyUnicode_AsEncodedObject`:
Use :c:func:`PyCodec_Encode` instead.
* :c:func:`!PyUnicode_AsEncodedUnicode`:
Use :c:func:`PyCodec_Encode` instead; Note that some codecs (for example, "base64")
may return a type other than :class:`bytes`, such as :class:`str`.

(Contributed by Stan Ulbrych in :gh:`133612`)

* :c:func:`!PyImport_ImportModuleNoBlock`: deprecated alias
of :c:func:`PyImport_ImportModule`.
57 changes: 0 additions & 57 deletions Include/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,49 +341,6 @@ PyAPI_FUNC(PyObject*) PyUnicode_Decode(
const char *errors /* error handling */
);

/* Decode a Unicode object unicode and return the result as Python
object.

This API is DEPRECATED and will be removed in 3.15.
The only supported standard encoding is rot13.
Use PyCodec_Decode() to decode with rot13 and non-standard codecs
that decode from str. */

Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject(
PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */
const char *errors /* error handling */
);

/* Decode a Unicode object unicode and return the result as Unicode
object.

This API is DEPRECATED and will be removed in 3.15.
The only supported standard encoding is rot13.
Use PyCodec_Decode() to decode with rot13 and non-standard codecs
that decode from str to str. */

Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode(
PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */
const char *errors /* error handling */
);

/* Encodes a Unicode object and returns the result as Python
object.

This API is DEPRECATED and will be removed in 3.15.
It is superseded by PyUnicode_AsEncodedString()
since all standard encodings (except rot13) encode str to bytes.
Use PyCodec_Encode() for encoding with rot13 and non-standard codecs
that encode form str to non-bytes. */

Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject(
PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */
const char *errors /* error handling */
);

/* Encodes a Unicode object and returns the result as Python string
object. */

Expand All @@ -393,20 +350,6 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString(
const char *errors /* error handling */
);

/* Encodes a Unicode object and returns the result as Unicode
object.

This API is DEPRECATED and will be removed in 3.15.
The only supported standard encodings is rot13.
Use PyCodec_Encode() to encode with rot13 and non-standard codecs
that encode from str to str. */

Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode(
PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */
const char *errors /* error handling */
);

/* Build an encoding map. */

PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Remove deprecated functions :c:func:`!PyUnicode_AsDecodedObject`,
:c:func:`!PyUnicode_AsDecodedUnicode`, :c:func:`!PyUnicode_AsEncodedObject`,
and :c:func:`!PyUnicode_AsEncodedUnicode`.
4 changes: 4 additions & 0 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1463,14 +1463,18 @@
added = '3.2'
[function.PyUnicode_AsDecodedObject]
added = '3.2'
abi_only = true
[function.PyUnicode_AsDecodedUnicode]
added = '3.2'
abi_only = true
[function.PyUnicode_AsEncodedObject]
added = '3.2'
abi_only = true
[function.PyUnicode_AsEncodedString]
added = '3.2'
[function.PyUnicode_AsEncodedUnicode]
added = '3.2'
abi_only = true
[function.PyUnicode_AsLatin1String]
added = '3.2'
[function.PyUnicode_AsRawUnicodeEscapeString]
Expand Down
33 changes: 4 additions & 29 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3730,7 +3730,7 @@ PyUnicode_Decode(const char *s,
return NULL;
}

PyObject *
PyAPI_FUNC(PyObject *)
PyUnicode_AsDecodedObject(PyObject *unicode,
const char *encoding,
const char *errors)
Expand All @@ -3740,20 +3740,14 @@ PyUnicode_AsDecodedObject(PyObject *unicode,
return NULL;
}

if (PyErr_WarnEx(PyExc_DeprecationWarning,
"PyUnicode_AsDecodedObject() is deprecated "
"and will be removed in 3.15; "
"use PyCodec_Decode() to decode from str", 1) < 0)
return NULL;

if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();

/* Decode via the codec registry */
return PyCodec_Decode(unicode, encoding, errors);
}

PyObject *
PyAPI_FUNC(PyObject *)
PyUnicode_AsDecodedUnicode(PyObject *unicode,
const char *encoding,
const char *errors)
Expand All @@ -3765,12 +3759,6 @@ PyUnicode_AsDecodedUnicode(PyObject *unicode,
goto onError;
}

if (PyErr_WarnEx(PyExc_DeprecationWarning,
"PyUnicode_AsDecodedUnicode() is deprecated "
"and will be removed in 3.15; "
"use PyCodec_Decode() to decode from str to str", 1) < 0)
return NULL;

if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();

Expand All @@ -3793,7 +3781,7 @@ PyUnicode_AsDecodedUnicode(PyObject *unicode,
return NULL;
}

PyObject *
PyAPI_FUNC(PyObject *)
PyUnicode_AsEncodedObject(PyObject *unicode,
const char *encoding,
const char *errors)
Expand All @@ -3805,13 +3793,6 @@ PyUnicode_AsEncodedObject(PyObject *unicode,
goto onError;
}

if (PyErr_WarnEx(PyExc_DeprecationWarning,
"PyUnicode_AsEncodedObject() is deprecated "
"and will be removed in 3.15; "
"use PyUnicode_AsEncodedString() to encode from str to bytes "
"or PyCodec_Encode() for generic encoding", 1) < 0)
return NULL;

if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();

Expand Down Expand Up @@ -4017,7 +3998,7 @@ PyUnicode_AsEncodedString(PyObject *unicode,
return NULL;
}

PyObject *
PyAPI_FUNC(PyObject *)
PyUnicode_AsEncodedUnicode(PyObject *unicode,
const char *encoding,
const char *errors)
Expand All @@ -4029,12 +4010,6 @@ PyUnicode_AsEncodedUnicode(PyObject *unicode,
goto onError;
}

if (PyErr_WarnEx(PyExc_DeprecationWarning,
"PyUnicode_AsEncodedUnicode() is deprecated "
"and will be removed in 3.15; "
"use PyCodec_Encode() to encode from str to str", 1) < 0)
return NULL;

if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();

Expand Down
Loading