classification
Title: The Python library will not compile with a C++2020 compiler because the code uses the reserved “module” keyword
Type: enhancement Stage: patch review
Components: C API Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: AliyevH, aCuria, petr.viktorin, serhiy.storchaka, vstinner
Priority: normal Keywords: easy (C), patch

Created on 2020-01-16 09:25 by aCuria, last changed 2021-09-15 18:54 by AliyevH.

Pull Requests
URL Status Linked Edit
PR 28359 closed AliyevH, 2021-09-15 17:02
PR 28373 closed AliyevH, 2021-09-15 18:54
Messages (9)
msg360103 - (view) Author: Keith (aCuria) Date: 2020-01-16 09:25
The Python library will not compile with a C++2020 compiler because the code uses the reserved “module” keyword
 
For example, in warnings.h, we have the following code:
 
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) PyErr_WarnExplicitObject(
    PyObject *category,
    PyObject *message,
    PyObject *filename,
    int lineno,
    PyObject *module,
PyObject *registry);
 
 
In modsupport.h we have the following code:
PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
 
We can fix this by using a different identifier, for example “pyModule” instead of “module”
msg360106 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-01-16 09:37
Names of arguments can be just removed from function declarations in header files.
msg360110 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-16 09:52
Qt has a similar issue with "slots": bpo-1086854 and bpo-38007.
msg360115 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-01-16 10:31
Qt has different issue. "slots" is not a keyword, and the issue can be avoided by including Python.h before Qt.h or undefining the "slots" macro.

It could be a harder issue if "module" would be a field name of a public structure. But names of arguments are not part of the API.
msg398915 - (view) Author: Hasan (AliyevH) * Date: 2021-08-04 17:05
If nobody works, i would like to solve this
msg399073 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-08-06 11:22
Please go ahead. Anyone is free to propose a fix.
msg399975 - (view) Author: Hasan (AliyevH) * Date: 2021-08-20 15:27
We have tested with cxx-modules that issue.
module is just a specifier for export (only export is a compiler-based keyword in >= C++20)
That's why we can use module as argument name and there's no need to rename or delete *module arguments from header files.

What do you recommend to do?

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1103r3.pdf
msg401109 - (view) Author: Keith (aCuria) Date: 2021-09-06 02:13
the word "module" should be treated as a reserved keyword.

Any use of "module" as an argument name should be changed to something else
throughout the code base.

On Fri, Aug 20, 2021 at 11:28 PM Hasan <report@bugs.python.org> wrote:

>
> Hasan <hasan.aleeyev@gmail.com> added the comment:
>
> We have tested with cxx-modules that issue.
> module is just a specifier for export (only export is a compiler-based
> keyword in >= C++20)
> That's why we can use module as argument name and there's no need to
> rename or delete *module arguments from header files.
>
> What do you recommend to do?
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1103r3.pdf
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue39355>
> _______________________________________
>
msg401778 - (view) Author: Hasan (AliyevH) * Date: 2021-09-14 12:39
Okey. There will be huge changes for this issue as this keyword has been used in a lot of places. 

That's why i will try to send pull requests module by module to keep it clean and simple for review.
History
Date User Action Args
2021-09-15 18:54:25AliyevHsetpull_requests: + pull_request26787
2021-09-15 17:02:23AliyevHsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request26773
2021-09-14 12:39:47AliyevHsetmessages: + msg401778
2021-09-06 02:13:43aCuriasetmessages: + msg401109
2021-08-20 15:27:05AliyevHsetmessages: + msg399975
2021-08-06 11:22:12vstinnersetmessages: + msg399073
2021-08-04 17:05:11AliyevHsetnosy: + AliyevH
messages: + msg398915
2021-06-22 14:40:32petr.viktorinsetnosy: + petr.viktorin
2020-01-16 10:31:54serhiy.storchakasetmessages: + msg360115
2020-01-16 09:52:11vstinnersetmessages: + msg360110
2020-01-16 09:37:16serhiy.storchakasettype: enhancement
versions: - Python 2.7, Python 3.5, Python 3.6
keywords: + easy (C)
nosy: + serhiy.storchaka

messages: + msg360106
stage: needs patch
2020-01-16 09:33:25xtreaksetnosy: + vstinner
2020-01-16 09:25:21aCuriacreate