Skip to content

Issue #21: Avoid C++ keyword module#22

Merged
vstinner merged 1 commit intopython:mainfrom
erlend-aasland:cpp-keywords/module
Feb 11, 2022
Merged

Issue #21: Avoid C++ keyword module#22
vstinner merged 1 commit intopython:mainfrom
erlend-aasland:cpp-keywords/module

Conversation

@erlend-aasland
Copy link
Copy Markdown

@erlend-aasland erlend-aasland commented Feb 11, 2022

Rename module variable/argument names as mod.

Fixes #21

Copy link
Copy Markdown
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

LGTM with easy solution but let's wait @vstinner 's review

@vstinner
Copy link
Copy Markdown
Member

Is it possible to detect the error using a C++ compiler warning to prevent adding new ones? The C++ compatibility is tested in tests/.

@erlend-aasland
Copy link
Copy Markdown
Author

Is it possible to detect the error using a C++ compiler warning to prevent adding new ones? The C++ compatibility is tested in tests/.

Good point. I'll add a test.

@vstinner
Copy link
Copy Markdown
Member

I guess that this PR is related to: https://bugs.python.org/issue39355

I don't get any warning:

$ cat x.cc 
int main() { int module = 1; return module; }
$ g++ -std=c++20 -Wall -Wextra x.cc -o x
# no warning

@vstinner vstinner merged commit ca6a60e into python:main Feb 11, 2022
@vstinner
Copy link
Copy Markdown
Member

I changed my mind. Python.h has the issue, so until Python will be fixed ( https://bugs.python.org/issue39355 https://bugs.python.org/issue39355 ) we cannot test it in pythoncapi_compat.h which includes Python.h. I don't want to add a test using a regex which would emit false alarm if the word "module" is used in a comment.

@vstinner
Copy link
Copy Markdown
Member

Thanks, I merged your fix!

@erlend-aasland
Copy link
Copy Markdown
Author

I changed my mind. Python.h has the issue, so until Python will be fixed ( https://bugs.python.org/issue39355 https://bugs.python.org/issue39355 ) we cannot test it in pythoncapi_compat.h which includes Python.h. I don't want to add a test using a regex which would emit false alarm if the word "module" is used in a comment.

Makes sense!

@erlend-aasland erlend-aasland deleted the cpp-keywords/module branch February 11, 2022 13:15
vstinner added a commit to vstinner/pythoncapi_compat that referenced this pull request Mar 29, 2022
vstinner added a commit that referenced this pull request Mar 29, 2022
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.

Avoid C++ keywords

3 participants