Skip to content

Build warnings about uses of deprecated CPython C API items #180

@ngoldbaum

Description

@ngoldbaum

When I build CFFI using 3.14rc1, I see:

  src/c/_cffi_backend.c:955:17: warning: '_PyLong_Sign' is deprecated [-Wdeprecated-declarations]
    955 |             if (_PyLong_Sign(ob) < 0)
        |                 ^
  /Users/goldbaum/.pyenv/versions/3.14.0rc1t/include/python3.14t/cpython/longobject.h:38:1: note: '_PyLong_Sign' has been explicitly marked deprecated here
     38 | Py_DEPRECATED(3.14) PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
        | ^
  /Users/goldbaum/.pyenv/versions/3.14.0rc1t/include/python3.14t/pyport.h:280:54: note: expanded from macro 'Py_DEPRECATED'
    280 | #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
        |                                                      ^
  src/c/_cffi_backend.c:4083:16: warning: '_PyLong_Sign' is deprecated [-Wdeprecated-declarations]
   4083 |         return _PyLong_Sign(ob) != 0;
        |                ^
  /Users/goldbaum/.pyenv/versions/3.14.0rc1t/include/python3.14t/cpython/longobject.h:38:1: note: '_PyLong_Sign' has been explicitly marked deprecated here
     38 | Py_DEPRECATED(3.14) PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
        | ^
  /Users/goldbaum/.pyenv/versions/3.14.0rc1t/include/python3.14t/pyport.h:280:54: note: expanded from macro 'Py_DEPRECATED'
    280 | #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
        |                                                      ^
  src/c/_cffi_backend.c:4658:22: warning: 'Py_FileSystemDefaultEncoding' is deprecated [-Wdeprecated-declarations]
   4658 |                      Py_FileSystemDefaultEncoding, &filename_or_null, &flags))
        |                      ^
  /Users/goldbaum/.pyenv/versions/3.14.0rc1t/include/python3.14t/fileobject.h:22:1: note: 'Py_FileSystemDefaultEncoding' has been explicitly marked deprecated here
     22 | Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
        | ^
  /Users/goldbaum/.pyenv/versions/3.14.0rc1t/include/python3.14t/pyport.h:280:54: note: expanded from macro 'Py_DEPRECATED'
    280 | #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
        |                                                      ^

For _PyLong_Sign, there is PyLong_GetSign in 3.14 and newer. https://docs.python.org/3.14/c-api/long.html#c.PyLong_GetSign

For Py_FileSystemDefaultEncoding, The 3.12 whatsnew entry says to use PyConfig.filesystem_encoding instead: https://docs.python.org/3/whatsnew/3.12.html#id6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions