[Python-Dev] API deprecations in Python 3, from a Python 2 perspective

Larry Hastings larry at hastings.org
Fri Mar 18 01:01:16 CET 2011


On 03/17/2011 07:23 PM, Terry Reedy wrote:
> As I understand it, the Pyxxx to PyCapsule CAPI warning was put in 2.7.

In 2.7, the CObject constructor PyCObject_FromVoidPtr() threw a 
PendingDeprecationWarning exception.  Like other warnings, these aren't 
active by default.  This still caused two problems:

    * If you enabled warnings, PyCObject_FromVoidPtr() would return
      NULL.  There is definitely code out there that assumes
      PyCObject_FromVoidPtr() always succeeds and doesn't bother
      checking the pointer it gets back.  That's a bad assumption, the
      code is therefore buggy--but exposing these heretofore unnoticed
      bugs caused problems.
    * If you enabled warnings-as-errors, a PendingDeprecationWarning is
      therefore an error.  In some environments there's a requirement
      that Python must build from scratch and pass its unit test suite
      without errors, with warnings-as-errors turned on.  Python 2.7
      shipped with one module still using PyCObject_FromVoidPtr(),
      bsddb, as it's externally maintained.  (I wanted to change it to
      use PyCapsule for 2.7 but was told to leave it alone.)  bsddb's
      test threw the warning, the warning was an error, now people had a
      problem.

In 2.7.1 PyCObject_FromVoidPtr() now calls PyErr_WarnPy3k().  This means 
it's been promoted to throwing DeprecationWarning!  But that's also 
guarded with Py_Py3kWarningFlag so it's not active unless you ask for 
that too (as with "-3" on the command-line, etc).


/larry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110317/6a4fed82/attachment.html>


More information about the Python-Dev mailing list