Cython: Cython 0.29.14 and Py38 generates warnings for tp_print

Created on 30 Mar 2020  Â·  4Comments  Â·  Source: cython/cython

ref https://github.com/pandas-dev/pandas/issues/30609#issuecomment-606121355

Cythonizing files with 0.29.14 and Python 3.8 produces warnings such as the following:

pandas/io/sas/sas.c:20457:3: error: 'tp_print' is deprecated [-Werror,-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/williamayd/miniconda3/envs/py38/include/python3.8/cpython/object.h:260:5: note: 'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/williamayd/miniconda3/envs/py38/include/python3.8/pyport.h:515:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
5 errors generated.

These did not appear in Cython 0.29.13. I think this may have to do with changes introduced in #3201

Most helpful comment

was the main reason to add the initializer…

Well, yes. The field is still there, so you get a warning if you don't initialise it. And since it is deprecated, you get a warning that you're accessing a deprecated field if you initialise it. Lovely.

All 4 comments

Yes, this is due to #3201.

Apparently, these warnings can be silenced, at least in gcc:
https://stackoverflow.com/questions/13459602/how-can-i-get-rid-of-deprecated-warnings-in-deprecated-functions-in-gcc/13459924#13459924

Failing that, it seems that at least someone may end up being unhappy here – whoever doesn't want to see deprecation warnings or whoever doesn't want to see "missing initialiser" warnings.

This whole thing feels a bit insane to me…

Cool thanks for the info! Actually I was bisecting yesterday and didn't see the warnings as introduced by that. It's possible I made a mistake on bisect, but at the same time could be a red herring. Will investigate further and post back

@scoder so reading through the issues, was the main reason to add the initializer in the first place to allow files that were cythonized on say 3.7 and earlier to still be compilable in a 3.8 environment without warning?

was the main reason to add the initializer…

Well, yes. The field is still there, so you get a warning if you don't initialise it. And since it is deprecated, you get a warning that you're accessing a deprecated field if you initialise it. Lovely.

Was this page helpful?
0 / 5 - 0 ratings