Skip to content

Commit db53258

Browse files
authored
PEP 624: Add rejected idea. (#1508)
New section describes why this PEP doesn't deprecate PyUnicode_Decode*** APIs.
1 parent bfdfd74 commit db53258

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pep-0624.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Type: Standards Track
66
Content-Type: text/x-rst
77
Created: 06-Jul-2020
88
Python-Version: 3.11
9+
Post-History: 08-Jul-2020
910

1011

1112
Abstract
@@ -263,6 +264,44 @@ runtime ``DeprecationWarning`` might not helpful for Python
263264
developers. We should warn to extension developers instead.
264265

265266

267+
Deprecate ``PyUnicode_Decode*`` APIs too
268+
----------------------------------------
269+
270+
Not only remove ``PyUnicode_Encode*()`` APIs, but also deprecate
271+
following APIs too for symmetry and reducing number of APIs.
272+
273+
* ``PyUnicode_DecodeASCII()``
274+
* ``PyUnicode_DecodeLatin1()``
275+
* ``PyUnicode_DecodeUTF7()``
276+
* ``PyUnicode_DecodeUTF8()``
277+
* ``PyUnicode_DecodeUTF16()``
278+
* ``PyUnicode_DecodeUTF32()``
279+
* ``PyUnicode_DecodeUnicodeEscape()``
280+
* ``PyUnicode_DecodeRawUnicodeEscape()``
281+
* ``PyUnicode_DecodeCharmap()``
282+
* ``PyUnicode_DecodeMBCS()``
283+
284+
This idea is excluded from this PEP because of several reasons:
285+
286+
* We can not remove them anytime soon because they are part of stable
287+
ABI.
288+
289+
* ``PyUnicode_DecodeASCII()`` and ``PyUnicode_DecodeUTF8()`` are used
290+
very widely. Deprecating them is not worth enough.
291+
292+
* Decoding from ``const char*`` is independent from Unicode
293+
representation.
294+
295+
* ``PyUnicode_Decode*()`` APIs are useful for applications and
296+
extensions using UTF-8 or Python Unicode objects to store Unicode
297+
string. But ``PyUnicode_Encode*()`` APIs are not useful for them.
298+
299+
* Python implementations using UTF-8 for Unicode internal
300+
representation (e.g. PyPy and micropython) may not have encoder
301+
with ``wchar_t*`` or UCS-4 input. But decoding from ``char*``
302+
is very natural for them too.
303+
304+
266305
Discussions
267306
===========
268307

0 commit comments

Comments
 (0)