This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yselivanov
Recipients ned.deily, yselivanov
Date 2018-09-21.15:06:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Unfortunately, the current C API for PEP 567 has a flaw: it uses non-PyObject pointers.  

This causes problems with integrating with tools like Cython, where PyObject is special and a lot of machinery recognizes it and manages refcounts correctly.

It also goes against the recent push to improve C API; one of the things we want to fix is to eliminate non-PyObject pointer types from public APIs entirely.

Because this C API is new (landed in 3.7.0) I think it might make sense to change it in 3.7.1.  I *think* this is a relatively safe (albeit annoying) change:

1. I don't expect that a lot of people use this new C API.  I googled recently if anyone uses contextvars at all, and found that some people are using the Python API.  The only user of C API that I'm aware of is uvloop, which I'll be happy to fix.

2. My current understanding is that this change won't break existing extensions compiled against Python 3.7.0, as it's just a change in pointers' types.

3. For example, clang spits out the following *warning* if it sees mismatched pointer types (and still compiles the extension):

   warning: incompatible pointer types passing 'PyContextVar *' (aka
      'struct _pycontextvarobject *') to parameter of type 'PyObject *' (aka 'struct _object *')

4. This would make it slightly harder to create extension that supports both 3.7.0 and 3.7.1 and compiles without warnings.  (It's possible to avoid warnings by adding some #ifdefs macro).

If we don't change this API now, we'll likely have to either live with it, or face a very slow deprecation period.
Date User Action Args
2018-09-21 15:06:32yselivanovsetrecipients: + yselivanov, ned.deily
2018-09-21 15:06:32yselivanovsetmessageid: <>
2018-09-21 15:06:32yselivanovlinkissue34762 messages
2018-09-21 15:06:32yselivanovcreate