New submission from Yury Selivanov <yseliva...@gmail.com>:

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 *')
      [-Wincompatible-pointer-types]

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.

----------
components: Interpreter Core
messages: 325989
nosy: ned.deily, yselivanov
priority: normal
severity: normal
status: open
title: Change contextvars C API to use PyObject
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to