PEP 624: Minor updates (#1666)

Remove Python 3.9 from plan, because it is released already.
Rewrite objections section.
This commit is contained in:
Inada Naoki 2020-10-20 17:42:54 +09:00 committed by GitHub
parent 3619926f14
commit 4e5d851eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 58 deletions

View File

@ -122,23 +122,7 @@ Notes:
Plan Plan
==== ====
Python 3.9 Remove these APIs in Python 3.11. They have been deprecated already.
----------
Add ``Py_DEPRECATED(3.3)`` to following APIs. This change is committed
already [3]_. All other APIs have been marked ``Py_DEPRECATED(3.3)``
already.
* ``PyUnicode_EncodeDecimal()``
* ``PyUnicode_TransformDecimalToASCII()``.
Document all APIs as "will be removed in version 3.11".
Python 3.11
-----------
These APIs are removed.
* ``PyUnicode_Encode()`` * ``PyUnicode_Encode()``
* ``PyUnicode_EncodeASCII()`` * ``PyUnicode_EncodeASCII()``
@ -259,47 +243,6 @@ If we emit Python warning from ``PyUnicode_EncodeUTF8()``, warning
filters and other threads may change the ``list`` and ``u`` can be filters and other threads may change the ``list`` and ``u`` can be
a dangling reference after ``PyUnicode_EncodeUTF8()`` returned. a dangling reference after ``PyUnicode_EncodeUTF8()`` returned.
Additionally, since we are not changing behavior but removing C APIs,
runtime ``DeprecationWarning`` might not helpful for Python
developers. We should warn to extension developers instead.
Deprecate ``PyUnicode_Decode*`` APIs too
----------------------------------------
Not only remove ``PyUnicode_Encode*()`` APIs, but also deprecate
following APIs too for symmetry and reducing number of APIs.
* ``PyUnicode_DecodeASCII()``
* ``PyUnicode_DecodeLatin1()``
* ``PyUnicode_DecodeUTF7()``
* ``PyUnicode_DecodeUTF8()``
* ``PyUnicode_DecodeUTF16()``
* ``PyUnicode_DecodeUTF32()``
* ``PyUnicode_DecodeUnicodeEscape()``
* ``PyUnicode_DecodeRawUnicodeEscape()``
* ``PyUnicode_DecodeCharmap()``
* ``PyUnicode_DecodeMBCS()``
This idea is excluded from this PEP because of several reasons:
* We can not remove them anytime soon because they are part of stable
ABI.
* ``PyUnicode_DecodeASCII()`` and ``PyUnicode_DecodeUTF8()`` are used
very widely. Deprecating them is not worth enough.
* Decoding from ``const char*`` is independent from Unicode
representation.
* ``PyUnicode_Decode*()`` APIs are useful for applications and
extensions using UTF-8 or Python Unicode objects to store Unicode
string. But ``PyUnicode_Encode*()`` APIs are not useful for them.
* Python implementations using UTF-8 for Unicode internal
representation (e.g. PyPy and micropython) may not have encoder
with ``wchar_t*`` or UCS-4 input. But decoding from ``char*``
is very natural for them too.
Discussions Discussions
@ -310,6 +253,27 @@ Discussions
* `bpo-41123: Remove Py_UNICODE APIs except PEP 623: <https://bugs.python.org/issue41123>`_ * `bpo-41123: Remove Py_UNICODE APIs except PEP 623: <https://bugs.python.org/issue41123>`_
Objections
----------
* Removing these APIs removes ability to use codec without temporary Unicode.
* Codecs can not encode Unicode buffer directly without temporary Unicode
object since Python 3.3. All these APIs creates temporary Unicode object
for now. So removing them doesn't reduce any abilities.
* Why not remove decoder APIs too?
* They are part of stable ABI.
* ``PyUnicode_DecodeASCII()`` and ``PyUnicode_DecodeUTF8()`` are used
very widely. Deprecating them is not worth enough.
* Decoder APIs can decode from byte buffer directly, without creating
temporary bytes object. On the other hand, encoder APIs can not avoid
temporary Unicode object.
References References
========== ==========