Skip to content

Commit e5963ee

Browse files
authored
What's New in Python 3.9: Reorganize C API Changes (GH-19794)
Move Build Changes and C API Changes to the end of the document. Most Python users don't build Python themselves and don't use the C API. Other changes: * Add Build Changes section * Add sub-sections to the C API Changes * Sort modules in Improved Modules section: move nntplib after multiprocessing
1 parent 5769724 commit e5963ee

File tree

1 file changed

+173
-159
lines changed

1 file changed

+173
-159
lines changed

Doc/whatsnew/3.9.rst

Lines changed: 173 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,6 @@ Add :func:`math.ulp`: return the value of the least significant bit
369369
of a float.
370370
(Contributed by Victor Stinner in :issue:`39310`.)
371371

372-
nntplib
373-
-------
374-
375-
:class:`~nntplib.NNTP` and :class:`~nntplib.NNTP_SSL` now raise a :class:`ValueError`
376-
if the given timeout for their constructor is zero to prevent the creation of
377-
a non-blocking socket. (Contributed by Dong-hee Na in :issue:`39259`.)
378-
379372
multiprocessing
380373
---------------
381374

@@ -384,6 +377,13 @@ The :class:`multiprocessing.SimpleQueue` class has a new
384377
queue.
385378
(Contributed by Victor Stinner in :issue:`30966`.)
386379

380+
nntplib
381+
-------
382+
383+
:class:`~nntplib.NNTP` and :class:`~nntplib.NNTP_SSL` now raise a :class:`ValueError`
384+
if the given timeout for their constructor is zero to prevent the creation of
385+
a non-blocking socket. (Contributed by Dong-hee Na in :issue:`39259`.)
386+
387387
os
388388
--
389389

@@ -534,157 +534,6 @@ Optimizations
534534
Stinner in :issue:`38061`.)
535535

536536

537-
Build and C API Changes
538-
=======================
539-
540-
* New :c:func:`PyFrame_GetCode` function: get a frame code.
541-
New :c:func:`PyFrame_GetBack` function: get the frame next outer frame.
542-
(Contributed by Victor Stinner in :issue:`40421`.)
543-
544-
* Add :c:func:`PyFrame_GetLineNumber` to the limited C API.
545-
(Contributed by Victor Stinner in :issue:`40421`.)
546-
547-
* New :c:func:`PyThreadState_GetInterpreter` and
548-
:c:func:`PyInterpreterState_Get` functions to get the interpreter.
549-
New :c:func:`PyThreadState_GetFrame` function to get the current frame of a
550-
Python thread state.
551-
New :c:func:`PyThreadState_GetID` function: get the unique identifier of a
552-
Python thread state.
553-
(Contributed by Victor Stinner in :issue:`39947`.)
554-
555-
* Add ``--with-platlibdir`` option to the ``configure`` script: name of the
556-
platform-specific library directory, stored in the new :attr:`sys.platlibdir`
557-
attribute. See :attr:`sys.platlibdir` attribute for more information.
558-
(Contributed by Jan Matějek, Matěj Cepl, Charalampos Stratakis and Victor Stinner in :issue:`1294959`.)
559-
560-
* Add a new public :c:func:`PyObject_CallNoArgs` function to the C API, which
561-
calls a callable Python object without any arguments. It is the most efficient
562-
way to call a callable Python object without any argument.
563-
(Contributed by Victor Stinner in :issue:`37194`.)
564-
565-
* The global variable :c:data:`PyStructSequence_UnnamedField` is now a constant
566-
and refers to a constant string.
567-
(Contributed by Serhiy Storchaka in :issue:`38650`.)
568-
569-
* Exclude ``PyFPE_START_PROTECT()`` and ``PyFPE_END_PROTECT()`` macros of
570-
``pyfpe.h`` from ``Py_LIMITED_API`` (stable API).
571-
(Contributed by Victor Stinner in :issue:`38835`.)
572-
573-
* The ``tp_print`` slot of :ref:`PyTypeObject <type-structs>` has been removed.
574-
It was used for printing objects to files in Python 2.7 and before. Since
575-
Python 3.0, it has been ignored and unused.
576-
(Contributed by Jeroen Demeyer in :issue:`36974`.)
577-
578-
* On non-Windows platforms, the :c:func:`setenv` and :c:func:`unsetenv`
579-
functions are now required to build Python.
580-
(Contributed by Victor Stinner in :issue:`39395`.)
581-
582-
* The ``COUNT_ALLOCS`` special build macro has been removed.
583-
(Contributed by Victor Stinner in :issue:`39489`.)
584-
585-
* Changes in the limited C API (if ``Py_LIMITED_API`` macro is defined):
586-
587-
* Provide :c:func:`Py_EnterRecursiveCall` and :c:func:`Py_LeaveRecursiveCall`
588-
as regular functions for the limited API. Previously, there were defined as
589-
macros, but these macros didn't compile with the limited C API which cannot
590-
access ``PyThreadState.recursion_depth`` field (the structure is opaque in
591-
the limited C API).
592-
593-
* Exclude the following functions from the limited C API:
594-
595-
* ``_Py_CheckRecursionLimit``
596-
* ``_Py_NewReference()``
597-
* ``_Py_ForgetReference()``
598-
* ``_PyTraceMalloc_NewReference()``
599-
* ``_Py_GetRefTotal()``
600-
* The trashcan mechanism which never worked in the limited C API.
601-
* ``PyTrash_UNWIND_LEVEL``
602-
* ``Py_TRASHCAN_BEGIN_CONDITION``
603-
* ``Py_TRASHCAN_BEGIN``
604-
* ``Py_TRASHCAN_END``
605-
* ``Py_TRASHCAN_SAFE_BEGIN``
606-
* ``Py_TRASHCAN_SAFE_END``
607-
608-
* The following static inline functions or macros become regular "opaque"
609-
function to hide implementation details:
610-
611-
* ``_Py_NewReference()``
612-
* ``PyObject_INIT()`` and ``PyObject_INIT_VAR()`` become aliases to
613-
:c:func:`PyObject_Init` and :c:func:`PyObject_InitVar` in the limited C
614-
API, but are overriden with static inline function otherwise. Thanks to
615-
that, it was possible to exclude ``_Py_NewReference()`` from the limited
616-
C API.
617-
618-
* Move following functions and definitions to the internal C API:
619-
620-
* ``_PyDebug_PrintTotalRefs()``
621-
* ``_Py_PrintReferences()``
622-
* ``_Py_PrintReferenceAddresses()``
623-
* ``_Py_tracemalloc_config``
624-
* ``_Py_AddToAllObjects()`` (specific to ``Py_TRACE_REFS`` build)
625-
626-
(Contributed by Victor Stinner in :issue:`38644` and :issue:`39542`.)
627-
628-
* ``PyInterpreterState.eval_frame`` (:pep:`523`) now requires a new mandatory
629-
*tstate* parameter (``PyThreadState*``).
630-
(Contributed by Victor Stinner in :issue:`38500`.)
631-
632-
* Extension modules: :c:member:`~PyModuleDef.m_traverse`,
633-
:c:member:`~PyModuleDef.m_clear` and :c:member:`~PyModuleDef.m_free`
634-
functions of :c:type:`PyModuleDef` are no longer called if the module state
635-
was requested but is not allocated yet. This is the case immediately after
636-
the module is created and before the module is executed
637-
(:c:data:`Py_mod_exec` function). More precisely, these functions are not called
638-
if :c:member:`~PyModuleDef.m_size` is greater than 0 and the module state (as
639-
returned by :c:func:`PyModule_GetState`) is ``NULL``.
640-
641-
Extension modules without module state (``m_size <= 0``) are not affected.
642-
643-
* If :c:func:`Py_AddPendingCall` is called in a subinterpreter, the function is
644-
now scheduled to be called from the subinterpreter, rather than being called
645-
from the main interpreter. Each subinterpreter now has its own list of
646-
scheduled calls.
647-
(Contributed by Victor Stinner in :issue:`39984`.)
648-
649-
* Remove ``_PyRuntime.getframe`` hook and remove ``_PyThreadState_GetFrame``
650-
macro which was an alias to ``_PyRuntime.getframe``. They were only exposed
651-
by the internal C API. Remove also ``PyThreadFrameGetter`` type.
652-
(Contributed by Victor Stinner in :issue:`39946`.)
653-
654-
* The :c:func:`PyModule_AddType` function is added to help adding a type to a module.
655-
(Contributed by Dong-hee Na in :issue:`40024`.)
656-
657-
* The Windows registry is no longer used to initialize :data:`sys.path` when
658-
the ``-E`` option is used. This is significant when embedding Python on
659-
Windows.
660-
(Contributed by Zackery Spytz in :issue:`8901`.)
661-
662-
* Add the functions :c:func:`PyObject_GC_IsTracked` and
663-
:c:func:`PyObject_GC_IsFinalized` to the public API to allow to query if
664-
Python objects are being currently tracked or have been already finalized by
665-
the garbage collector respectively. (Contributed by Pablo Galindo in
666-
:issue:`40241`.)
667-
668-
* Remove the following functions from the C API. Call :c:func:`PyGC_Collect`
669-
explicitly to clear all free lists.
670-
(Contributed by Inada Naoki and Victor Stinner in :issue:`37340`,
671-
:issue:`38896` and :issue:`40428`.)
672-
673-
* ``PyAsyncGen_ClearFreeLists()``
674-
* ``PyContext_ClearFreeList()``
675-
* ``PyDict_ClearFreeList()``
676-
* ``PyFloat_ClearFreeList()``
677-
* ``PyFrame_ClearFreeList()``
678-
* ``PyList_ClearFreeList()``
679-
* ``PyMethod_ClearFreeList()`` and ``PyCFunction_ClearFreeList()``:
680-
the free lists of bound method objects have been removed.
681-
* ``PySet_ClearFreeList()``: the set free list has been removed
682-
in Python 3.4.
683-
* ``PyTuple_ClearFreeList()``
684-
* ``PyUnicode_ClearFreeList()``: the Unicode free list has been removed in
685-
Python 3.3.
686-
687-
688537
Deprecated
689538
==========
690539

@@ -729,7 +578,7 @@ Deprecated
729578
deprecated and will be removed in version 3.11.
730579
(Contributed by Yury Selivanov and Kyle Stanley in :issue:`34790`.)
731580

732-
* binhex4 and hexbin4 standards are now deprecated. The :`binhex` module
581+
* binhex4 and hexbin4 standards are now deprecated. The :mod:`binhex` module
733582
and the following :mod:`binascii` functions are now deprecated:
734583

735584
* :func:`~binascii.b2a_hqx`, :func:`~binascii.a2b_hqx`
@@ -934,3 +783,168 @@ CPython bytecode changes
934783
:keyword:`assert` statement. Previously, the assert statement would not work
935784
correctly if the :exc:`AssertionError` exception was being shadowed.
936785
(Contributed by Zackery Spytz in :issue:`34880`.)
786+
787+
788+
Build Changes
789+
=============
790+
791+
* Add ``--with-platlibdir`` option to the ``configure`` script: name of the
792+
platform-specific library directory, stored in the new :attr:`sys.platlibdir`
793+
attribute. See :attr:`sys.platlibdir` attribute for more information.
794+
(Contributed by Jan Matějek, Matěj Cepl, Charalampos Stratakis
795+
and Victor Stinner in :issue:`1294959`.)
796+
797+
* The ``COUNT_ALLOCS`` special build macro has been removed.
798+
(Contributed by Victor Stinner in :issue:`39489`.)
799+
800+
* On non-Windows platforms, the :c:func:`setenv` and :c:func:`unsetenv`
801+
functions are now required to build Python.
802+
(Contributed by Victor Stinner in :issue:`39395`.)
803+
804+
805+
C API Changes
806+
=============
807+
808+
New Features
809+
------------
810+
811+
* Add :c:func:`PyFrame_GetCode` function: get a frame code.
812+
Add :c:func:`PyFrame_GetBack` function: get the frame next outer frame.
813+
(Contributed by Victor Stinner in :issue:`40421`.)
814+
815+
* Add :c:func:`PyFrame_GetLineNumber` to the limited C API.
816+
(Contributed by Victor Stinner in :issue:`40421`.)
817+
818+
* Add :c:func:`PyThreadState_GetInterpreter` and
819+
:c:func:`PyInterpreterState_Get` functions to get the interpreter.
820+
Add :c:func:`PyThreadState_GetFrame` function to get the current frame of a
821+
Python thread state.
822+
Add :c:func:`PyThreadState_GetID` function: get the unique identifier of a
823+
Python thread state.
824+
(Contributed by Victor Stinner in :issue:`39947`.)
825+
826+
* Add a new public :c:func:`PyObject_CallNoArgs` function to the C API, which
827+
calls a callable Python object without any arguments. It is the most efficient
828+
way to call a callable Python object without any argument.
829+
(Contributed by Victor Stinner in :issue:`37194`.)
830+
831+
* Changes in the limited C API (if ``Py_LIMITED_API`` macro is defined):
832+
833+
* Provide :c:func:`Py_EnterRecursiveCall` and :c:func:`Py_LeaveRecursiveCall`
834+
as regular functions for the limited API. Previously, there were defined as
835+
macros, but these macros didn't compile with the limited C API which cannot
836+
access ``PyThreadState.recursion_depth`` field (the structure is opaque in
837+
the limited C API).
838+
839+
* ``PyObject_INIT()`` and ``PyObject_INIT_VAR()`` become regular "opaque"
840+
function to hide implementation details.
841+
842+
(Contributed by Victor Stinner in :issue:`38644` and :issue:`39542`.)
843+
844+
* The :c:func:`PyModule_AddType` function is added to help adding a type
845+
to a module.
846+
(Contributed by Dong-hee Na in :issue:`40024`.)
847+
848+
* Add the functions :c:func:`PyObject_GC_IsTracked` and
849+
:c:func:`PyObject_GC_IsFinalized` to the public API to allow to query if
850+
Python objects are being currently tracked or have been already finalized by
851+
the garbage collector respectively. (Contributed by Pablo Galindo in
852+
:issue:`40241`.)
853+
854+
855+
Porting to Python 3.9
856+
---------------------
857+
858+
* ``PyInterpreterState.eval_frame`` (:pep:`523`) now requires a new mandatory
859+
*tstate* parameter (``PyThreadState*``).
860+
(Contributed by Victor Stinner in :issue:`38500`.)
861+
862+
* Extension modules: :c:member:`~PyModuleDef.m_traverse`,
863+
:c:member:`~PyModuleDef.m_clear` and :c:member:`~PyModuleDef.m_free`
864+
functions of :c:type:`PyModuleDef` are no longer called if the module state
865+
was requested but is not allocated yet. This is the case immediately after
866+
the module is created and before the module is executed
867+
(:c:data:`Py_mod_exec` function). More precisely, these functions are not called
868+
if :c:member:`~PyModuleDef.m_size` is greater than 0 and the module state (as
869+
returned by :c:func:`PyModule_GetState`) is ``NULL``.
870+
871+
Extension modules without module state (``m_size <= 0``) are not affected.
872+
873+
* If :c:func:`Py_AddPendingCall` is called in a subinterpreter, the function is
874+
now scheduled to be called from the subinterpreter, rather than being called
875+
from the main interpreter. Each subinterpreter now has its own list of
876+
scheduled calls.
877+
(Contributed by Victor Stinner in :issue:`39984`.)
878+
879+
* The Windows registry is no longer used to initialize :data:`sys.path` when
880+
the ``-E`` option is used (if :c:member:`PyConfig.use_environment` is set to
881+
``0``). This is significant when embedding Python on Windows.
882+
(Contributed by Zackery Spytz in :issue:`8901`.)
883+
884+
* The global variable :c:data:`PyStructSequence_UnnamedField` is now a constant
885+
and refers to a constant string.
886+
(Contributed by Serhiy Storchaka in :issue:`38650`.)
887+
888+
889+
Removed
890+
-------
891+
892+
* Exclude ``PyFPE_START_PROTECT()`` and ``PyFPE_END_PROTECT()`` macros of
893+
``pyfpe.h`` from the limited C API.
894+
(Contributed by Victor Stinner in :issue:`38835`.)
895+
896+
* The ``tp_print`` slot of :ref:`PyTypeObject <type-structs>` has been removed.
897+
It was used for printing objects to files in Python 2.7 and before. Since
898+
Python 3.0, it has been ignored and unused.
899+
(Contributed by Jeroen Demeyer in :issue:`36974`.)
900+
901+
* Changes in the limited C API (if ``Py_LIMITED_API`` macro is defined):
902+
903+
* Exclude the following functions from the limited C API:
904+
905+
* ``_Py_CheckRecursionLimit``
906+
* ``_Py_NewReference()``
907+
* ``_Py_ForgetReference()``
908+
* ``_PyTraceMalloc_NewReference()``
909+
* ``_Py_GetRefTotal()``
910+
* The trashcan mechanism which never worked in the limited C API.
911+
* ``PyTrash_UNWIND_LEVEL``
912+
* ``Py_TRASHCAN_BEGIN_CONDITION``
913+
* ``Py_TRASHCAN_BEGIN``
914+
* ``Py_TRASHCAN_END``
915+
* ``Py_TRASHCAN_SAFE_BEGIN``
916+
* ``Py_TRASHCAN_SAFE_END``
917+
918+
* Move following functions and definitions to the internal C API:
919+
920+
* ``_PyDebug_PrintTotalRefs()``
921+
* ``_Py_PrintReferences()``
922+
* ``_Py_PrintReferenceAddresses()``
923+
* ``_Py_tracemalloc_config``
924+
* ``_Py_AddToAllObjects()`` (specific to ``Py_TRACE_REFS`` build)
925+
926+
(Contributed by Victor Stinner in :issue:`38644` and :issue:`39542`.)
927+
928+
* Remove ``_PyRuntime.getframe`` hook and remove ``_PyThreadState_GetFrame``
929+
macro which was an alias to ``_PyRuntime.getframe``. They were only exposed
930+
by the internal C API. Remove also ``PyThreadFrameGetter`` type.
931+
(Contributed by Victor Stinner in :issue:`39946`.)
932+
933+
* Remove the following functions from the C API. Call :c:func:`PyGC_Collect`
934+
explicitly to clear all free lists.
935+
(Contributed by Inada Naoki and Victor Stinner in :issue:`37340`,
936+
:issue:`38896` and :issue:`40428`.)
937+
938+
* ``PyAsyncGen_ClearFreeLists()``
939+
* ``PyContext_ClearFreeList()``
940+
* ``PyDict_ClearFreeList()``
941+
* ``PyFloat_ClearFreeList()``
942+
* ``PyFrame_ClearFreeList()``
943+
* ``PyList_ClearFreeList()``
944+
* ``PyMethod_ClearFreeList()`` and ``PyCFunction_ClearFreeList()``:
945+
the free lists of bound method objects have been removed.
946+
* ``PySet_ClearFreeList()``: the set free list has been removed
947+
in Python 3.4.
948+
* ``PyTuple_ClearFreeList()``
949+
* ``PyUnicode_ClearFreeList()``: the Unicode free list has been removed in
950+
Python 3.3.

0 commit comments

Comments
 (0)