Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-46543: add sys._getcaller#30950

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
JelleZijlstra wants to merge9 commits intopython:mainfromJelleZijlstra:sys_getcall

Conversation

@JelleZijlstra
Copy link
Member

@JelleZijlstraJelleZijlstra commentedJan 27, 2022
edited by bedevere-bot
Loading

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

Implementation looks sound. A couple of minor issues.

@markshannon
Copy link
Member

I don't like the name_getfunc, as explained infaster-cpython/ideas#238 (comment)

@JelleZijlstra
Copy link
MemberAuthor

Thanks, I'll go back to_getcaller based on the discussion on faster-cpython.

@gvanrossumgvanrossum changed the titlebpo-46543: add sys._getfuncbpo-46543: add sys._getcallerFeb 8, 2022
@JelleZijlstra
Copy link
MemberAuthor

@markshannon would you still like this to make it into 3.11?

@Fidget-Spinner
Copy link
Member

@JelleZijlstra I don't know about Mark, but personally I'd like to see it in 3.11. Would my review be enough? (I've held off reviewing since it's draft).

@markshannon
Copy link
Member

Unfortunately there are a few problems with this, which stem fromfunction.__code__ being mutable.

  1. Promoting the use ofsys._getcaller instead ofsys._getframe is flawed when you want the code object, as the caller function's__code__ attribute may have changed so thatsys._getcaller(1).__code__ != sys.getframe(1).f_code which would be surprising. Changing the__code__ attribute of a function is a weird thing to do, so this might be OK.
  2. As internal structs cease to be part of the C-API, we may be able to implementSpeed up frame handling in Python-to-Python calls. faster-cpython/ideas#111 which would mean that a reference to the caller function would no longer be available.
  3. In terms of Python semantics, a frame is defined by the (code, globals, builtins, locals) quad, not by the function from which it originally derived. The API should probably reflect that.

This was my idea originally, sorry for not spotting these flaws earlier.

@gvanrossum
Copy link
Member

Then should we just close this?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@markshannonmarkshannonmarkshannon left review comments

@ethanfurmanethanfurmanAwaiting requested review from ethanfurmanethanfurman is a code owner

@Fidget-SpinnerFidget-SpinnerAwaiting requested review from Fidget-Spinner

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@AlexWaygoodAlexWaygoodAwaiting requested review from AlexWaygoodAlexWaygood will be requested when the pull request is marked ready for reviewAlexWaygood is a code owner

@rhettingerrhettingerAwaiting requested review from rhettingerrhettinger will be requested when the pull request is marked ready for reviewrhettinger is a code owner

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently will be requested when the pull request is marked ready for reviewericsnowcurrently is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@JelleZijlstra@markshannon@Fidget-Spinner@gvanrossum@the-knights-who-say-ni@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp