gh-99202: Fix extension type from documentation for compiling in C++20 mode #102518
gh-99202: Fix extension type from documentation for compiling in C++20 mode #102518vstinner merged 8 commits intopython:mainfrom
Conversation
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
|
@vstinner @encukou @erlend-aasland @bruno-at-bareos as participants of the parent issue. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. IMO it's fine to use this syntax in the documentation for new extensions.
@encukou: What do you think?
Python 3.11 itself now targets C11: https://peps.python.org/pep-0007/#c-dialect Python still supports building extensions with older C standards and various C++ standards.
|
This actually looks great! I'm surprised that there aren't any obvious downsides! IMO it would be nice to introduce Victor, do you want to merge? (I can't commit to watching/fixing buildbots this week.) |
|
Merged, thanks! |
As noted in #99202, C++20 added support for designated initializers and fails to compile if you mix named and unnamed initializers.
The documentation currently includes a section "Defining Extension Types: Tutorial" that mixed named and unnamed initializers, so it will not compile as shown.
This PR adds names on the header macros, so they do now compile in C++20 mode. The change is only made in the demo documentation, not any "real" code.