8000 Py_NoSiteFlag is not needed since Python 3.8 by pemensik · Pull Request #1049 · NLnetLabs/unbound · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py_NoSiteFlag is not needed since Python 3.8 #1049

Conversation

pemensik
Copy link
Contributor

Python since 3.12 prints warning about Py_NoSiteFlag is deprecated. It seems that variable is not needed since Python 3.8, since it sets in such cases directly config.site_import variable few moments later. Move using deprecated variable to versions before that flag in config could be used only.

This should fix warning like:

pythonmod/pythonmod.c: In function 'pythonmod_init': pythonmod/pythonmod.c:359:7: warning: 'Py_NoSiteFlag' is deprecated [-Wdeprecated-declarations]
359 | Py_NoSiteFlag = 1;
| ^~~~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:48,
from pythonmod/pythonmod.c:54:
/usr/include/python3.12/cpython/pydebug.h:14:37: note: declared here
14 | Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoSiteFlag;
| ^~~~~~~~~~~~~

https://docs.python.org/3/c-api/init.html#c.Py_NoSiteFlag

Python since 3.12 prints warning about Py_NoSiteFlag is deprecated. It
seems that variable is not needed since Python 3.8, since it sets in
such cases directly config.site_import variable few moments later.
Move using deprecated variable to versions before that flag in config
could be used only.

This should fix warning like:

pythonmod/pythonmod.c: In function 'pythonmod_init':
pythonmod/pythonmod.c:359:7: warning: 'Py_NoSiteFlag' is deprecated [-Wdeprecated-declarations]
  359 |       Py_NoSiteFlag = 1;
      |       ^~~~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:48,
                 from pythonmod/pythonmod.c:54:
/usr/include/python3.12/cpython/pydebug.h:14:37: note: declared here
   14 | Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoSiteFlag;
      |                                     ^~~~~~~~~~~~~

https://docs.python.org/3/c-api/init.html#c.Py_NoSiteFlag
@pemensik
Copy link
Contributor Author

I have checked this compiles on:

  • Fedora 39 with python 3.12
  • Fedora 38 with python 3.11
  • CentOS Stream 9 with python 3.9
  • CentOS Stream 8 with python 3.6

But otherwise I have not done functional testing. It seems safe to me.

@gthess gthess self-assigned this Apr 15, 2024
Copy link
Member
@gthess gthess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Now the variable is used in old versions before Py_Initialize() is called and in newer versions config.site_import = 0 is used before Py_InitializeFromConfig() is called ensuring the same behavior for both old and newer Python versions.
Thanks!

@gthess gthess merged commit d71f257 into NLnetLabs:master Apr 15, 2024
1 check passed
gthess added a commit that referenced this pull request Apr 15, 2024
- Merge #1049 from Petr Menšík: Py_NoSiteFlag is not needed since
  Python 3.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0