Fix PEP 567 to reflect changes in 3.7.1 (see bpo-34762) (GH-787)

This commit is contained in:
Yury Selivanov 2018-09-21 15:37:11 -04:00 committed by GitHub
parent 04be11d785
commit 977a94d1a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 10 deletions

View File

@ -30,6 +30,24 @@ Although it does provide a mechanism that can be used by Context
Managers to store their state.
API Design and Implementation Revisions
=======================================
In **Python 3.7.1** the signatures of all context variables
C APIs were **changed** to use ``PyObject *`` pointers instead
of ``PyContext *``, ``PyContextVar *``, and ``PyContextToken *``,
e.g.::
// in 3.7.0:
PyContext *PyContext_New(void);
// in 3.7.1+:
PyObject *PyContext_New(void);
See [6]_ for more details. The `C API`_ section of this PEP was
updated to reflect the change.
Rationale
=========
@ -535,11 +553,11 @@ Python API
C API
-----
1. ``PyContextVar * PyContextVar_New(char *name, PyObject *default)``:
1. ``PyObject * PyContextVar_New(char *name, PyObject *default)``:
create a ``ContextVar`` object. The *default* argument can be
``NULL``, which means that the variable has no default value.
2. ``int PyContextVar_Get(PyContextVar *, PyObject *default_value, PyObject **value)``:
2. ``int PyContextVar_Get(PyObject *, PyObject *default_value, PyObject **value)``:
return ``-1`` if an error occurs during the lookup, ``0`` otherwise.
If a value for the context variable is found, it will be set to the
``value`` pointer. Otherwise, ``value`` will be set to
@ -548,26 +566,26 @@ C API
variable, which can be ``NULL`` too. ``value`` is always a new
reference.
3. ``PyContextToken * PyContextVar_Set(PyContextVar *, PyObject *)``:
3. ``PyObject * PyContextVar_Set(PyObject *, PyObject *)``:
set the value of the variable in the current context.
4. ``PyContextVar_Reset(PyContextVar *, PyContextToken *)``:
4. ``PyContextVar_Reset(PyObject *, PyObject *)``:
reset the value of the context variable.
5. ``PyContext * PyContext_New()``: create a new empty context.
5. ``PyObject * PyContext_New()``: create a new empty context.
6. ``PyContext * PyContext_Copy(PyContext *)``: return a shallow
6. ``PyObject * PyContext_Copy(PyObject *)``: return a shallow
copy of the passed context object.
7. ``PyContext * PyContext_CopyCurrent()``: get a copy of the current
7. ``PyObject * PyContext_CopyCurrent()``: get a copy of the current
context.
8. ``int PyContext_Enter(PyContext *)`` and
``int PyContext_Exit(PyContext *)`` allow to set and restore
8. ``int PyContext_Enter(PyObject *)`` and
``int PyContext_Exit(PyObject *)`` allow to set and restore
the context for the current OS thread. It is required to always
restore the previous context::
PyContext *old_ctx = PyContext_Copy();
PyObject *old_ctx = PyContext_Copy();
if (old_ctx == NULL) goto error;
if (PyContext_Enter(new_ctx)) goto error;
@ -858,6 +876,8 @@ References
.. [5] https://mail.python.org/pipermail/python-dev/2018-January/151878.html
.. [6] https://bugs.python.org/issue34762
Acknowledgments
===============