GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-92898: Make _Py_Cast C++ version compatible with cast operator by serge-sans-paille · Pull Request #92951 · python/cpython

Conversation

@serge-sans-paille

@serge-sans-paille serge-sans-paille commented May 19, 2022

Copy link
Copy Markdown
Contributor

Use the adequate kind of cast based on the macro argument: const ref, cont
pointer, ref or pointer.

This should be compatible with C++ overloads.

Fix #92898

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-bot bedevere-bot added the awaiting review label May 19, 2022
@serge-sans-paille
serge-sans-paille force-pushed the feature/fix-92898 branch from cf741a4 to 3f287c5 Compare May 19, 2022 10:06
@serge-sans-paille

serge-sans-paille commented May 19, 2022

Copy link
Copy Markdown
Contributor Author

cc @vstinner

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
corona10 requested review from corona10 and vstinner May 19, 2022 13:24
@corona10 corona10 added skip news needs backport to 3.11 only security fixes and removed skip news labels May 19, 2022
corona10
corona10 requested changes May 19, 2022
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Would you like to add NEWS.d about compatible?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot removed the awaiting review label May 19, 2022
@bedevere-bot

bedevere-bot commented May 19, 2022

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting changes label May 19, 2022
corona10
corona10 reviewed May 19, 2022
View reviewed changes
Comment thread Lib/test/_testcppext.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serge-sans-paille
serge-sans-paille force-pushed the feature/fix-92898 branch from e275be9 to 2e6b74a Compare May 19, 2022 13:27
@serge-sans-paille

serge-sans-paille commented May 19, 2022

Copy link
Copy Markdown
Contributor Author

@corona10 I'm not sure, there's already an entry

.. date: 2022-04-26-16-51-31
.. gh-issue: 91320
.. nonce: QDHmTv
.. section: C API

Fix C++ compiler warnings about "old-style cast" (``g++ -Wold-style-cast``)
in the Python C API. Use C++ ``reinterpret_cast<>`` and ``static_cast<>``
casts when the Python C API is used in C++. Patch by Victor Stinner.

And this is just patching that entry

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented May 19, 2022

Copy link
Copy Markdown
Contributor

I am now seeing errors compiling numpy with this branch:

      In file included from /home/tcaswell/.pybuild/bleeding/include/python3.12/Python.h:38,
                       from numpy/core/include/numpy/npy_common.h:5,
                       from numpy/core/include/numpy/npy_math.h:8,
                       from numpy/core/src/npysort/selection.cpp:18:
      /home/tcaswell/.pybuild/bleeding/include/python3.12/pyport.h:31:1: error: template with C linkage
         31 | template <typename type, typename expr_type>
            | ^~~~~~~~
      numpy/core/include/numpy/npy_math.h:5:1: note: ‘extern "C"’ linkage started here
          5 | extern "C" {
            | ^~~~~~~~~~
      /home/tcaswell/.pybuild/bleeding/include/python3.12/pyport.h:36:1: error: template with C linkage
         36 | template <typename type, typename expr_type>
            | ^~~~~~~~
      numpy/core/include/numpy/npy_math.h:5:1: note: ‘extern "C"’ linkage started here
          5 | extern "C" {
            | ^~~~~~~~~~
      /home/tcaswell/.pybuild/bleeding/include/python3.12/pyport.h:41:1: error: template with C linkage
         41 | template <typename type, typename expr_type>
            | ^~~~~~~~
      numpy/core/include/numpy/npy_math.h:5:1: note: ‘extern "C"’ linkage started here
          5 | extern "C" {
            | ^~~~~~~~~~
      /home/tcaswell/.pybuild/bleeding/include/python3.12/pyport.h:46:1: error: template with C linkage
         46 | template <typename type, typename expr_type>
            | ^~~~~~~~
      numpy/core/include/numpy/npy_math.h:5:1: note: ‘extern "C"’ linkage started here
          5 | extern "C" {
            | ^~~~~~~~~~

g++ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DNO_ATLAS_INFO=1 -DHAVE_CBLAS -I/usr/local/include -I/home/tcaswell/.virtualenvs/bleeding/include -Ibuild/src.linux-x86_64-3.12/numpy/core/src/multiarray -Ibuild/src.linux-x86_64-3.12/numpy/core/src/common -Ibuild/src.linux-x86_64-3.12/numpy/core/src/umath -Inumpy/core/include -Ibuild/src.linux-x86_64-3.12/numpy/core/include/numpy -Ibuild/src.linux-x86_64-3.12/numpy/distutils/include -Ibuild/src.linux-x86_64-3.12/numpy/core/src/npysort -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/home/tcaswell/.virtualenvs/bleeding/include -I/home/tcaswell/.pybuild/bleeding/include/python3.12 -Ibuild/src.linux-x86_64-3.12/numpy/core/src/common -Ibuild/src.linux-x86_64-3.12/numpy/core/src/npymath -c numpy/core/src/npysort/selection.cpp -o build/temp.linux-x86_64-3.12/numpy/core/src/npysort/selection.o -MMD -MF build/temp.linux-x86_64-3.12/numpy/core/src/npysort/selection.o.d -msse -msse2 -msse3 -std=c++11 -D__STDC_VERSION__=0 -fno-exceptions -fno-rtti
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serge-sans-paille

serge-sans-paille commented May 19, 2022

Copy link
Copy Markdown
Contributor Author

@tacaswell indeed. I can work around this :-)

tacaswell reacted with hooray emoji erlend-aasland reacted with eyes emoji
All reactions
  • 🎉 1 reaction
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented May 19, 2022

Copy link
Copy Markdown
Contributor

@serge-sans-paille I should note this is with numpy main, I have not gone back to see if released versions work or not.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serge-sans-paille
Make _Py_Cast C++ version compatible with cast operator
636d461
Use the adequate kind of cast based on the macro argument: const ref, cont
pointer, ref or pointer.

This should be compatible with C++ overloads.

Fix python#92898
@serge-sans-paille
serge-sans-paille force-pushed the feature/fix-92898 branch from 2e6b74a to 636d461 Compare May 19, 2022 18:27
@serge-sans-paille

serge-sans-paille commented May 19, 2022

Copy link
Copy Markdown
Contributor Author

@tacaswell should be good now?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented May 19, 2022

Copy link
Copy Markdown
Contributor

Through numpy, starting scipy. Will update if the whole environment builds cleanly (including greenlet main).

erlend-aasland reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented May 19, 2022

Copy link
Copy Markdown
Contributor

It built clean including master-branch greenlet 👍🏻

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 19, 2022
py311 issues with const correctness python-greenlet/greenlet#301
Closed
Clarify that const is being cast away python-greenlet/greenlet#302
Closed
corona10
corona10 approved these changes May 21, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting changes labels May 21, 2022
@corona10 corona10 added the skip news label May 21, 2022
@corona10
corona10 merged commit 5b71b51 into python:main May 21, 2022
@miss-islington

miss-islington commented May 21, 2022

Copy link
Copy Markdown
Contributor

Thanks @serge-sans-paille for the PR, and @corona10 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting merge label May 21, 2022
@miss-islington

miss-islington commented May 21, 2022

Copy link
Copy Markdown
Contributor

Sorry @serge-sans-paille and @corona10, I had trouble checking out the 3.11 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 5b71b519f966e1017c868ea2b27c61a5eac38c1f 3.11

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington miss-islington assigned corona10 May 21, 2022
corona10 pushed a commit to corona10/cpython that referenced this pull request May 21, 2022
@serge-sans-paille @corona10
[3.11] pythonGH-92898: Make _Py_Cast C++ version compatible with cast…
1190ed1
… operator (pythongh-92951)

(cherry picked from commit 5b71b51)

Co-authored-by: serge-sans-paille <[email protected]>
@corona10 corona10 mentioned this pull request May 21, 2022
[3.11] GH-92898: Make _Py_Cast C++ version compatible with cast opera… #93049
Merged
corona10 added a commit that referenced this pull request May 21, 2022
@corona10
[3.11] GH-92898: Make _Py_Cast C++ version compatible with cast opera…
dd923c5
…tor (gh-92951) (gh-93049)
@vstinner vstinner mentioned this pull request May 23, 2022
gh-92898: Enhance _testcppext test on cast to PyObject* #93111
Merged
@vstinner

vstinner commented May 23, 2022

Copy link
Copy Markdown
Member

I created a follow-up PR: #93111

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja hauntsaninja added needs backport to 3.11 only security fixes and removed needs backport to 3.11 only security fixes labels Dec 24, 2022
@miss-islington

miss-islington commented Dec 24, 2022

Copy link
Copy Markdown
Contributor

Thanks @serge-sans-paille for the PR, and @corona10 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Dec 24, 2022

Copy link
Copy Markdown
Contributor

Sorry, @serge-sans-paille and @corona10, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 5b71b519f966e1017c868ea2b27c61a5eac38c1f 3.11

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@terryjreedy terryjreedy removed the needs backport to 3.11 only security fixes label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@corona10 corona10 corona10 approved these changes
@vstinner vstinner Awaiting requested review from vstinner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@corona10 corona10

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

changes to PyObject casting macros causing build failures with python-greenlet

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@serge-sans-paille @bedevere-bot @tacaswell @miss-islington @vstinner @corona10 @hauntsaninja @terryjreedy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.