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

GH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque for users of PEP 523.#96849

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

Merged

Conversation

markshannon
Copy link
Member

@markshannonmarkshannon commentedSep 15, 2022
edited by bedevere-bot
Loading

Copy link
Member

@pablogsalpablogsal left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1,9 @@
Expose C-API functions to get the code object, lasti and line number from
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this needs a news entry since the functions are exposed technically on a private header.


/* Returns the currently executing line number, or -1 if there is no line number.
* Does not raise an exception. */
PyAPI_FUNC(int) _PyInterpreterFrame_GetLine(struct _PyInterpreterFrame *frame);
Copy link
Member

Choose a reason for hiding this comment

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

Usingstruct here is confusing the Windows compiler

Copy link
Member

Choose a reason for hiding this comment

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

You can addstruct _PyInterpreterFrame; somewhere to declare that "this structure exists" without having to declare the structure members (so it's declared as an opaque structure), to avoid such compiler warning. For example, at the top of this file.

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

Maybe added these functions to cpython/pyframe.h instead.

I don't know why frameobject.h is not included by Python.h: you have to include it explicitly, which goes against the advice of only including Python.h in C extensions. So I recently added pyframe.h which is included by Python.h. Maybe we should just move frameobject.h content into pyframe.h.

In Python 3.11, I moved multiple functions from frameobject.h to pyframe.h:27b9894

@@ -118,6 +118,20 @@ _PyFrame_Clear(_PyInterpreterFrame *frame)
Py_DECREF(frame->f_code);
}

/* Limited API functions */
Copy link
Member

Choose a reason for hiding this comment

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

These functions are excluded from the limited API, they are declared in cpython/.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

What is the part of the API that isn't portable called? "unlimited", "non-limited"?

Copy link
Member

Choose a reason for hiding this comment

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

The Limited API is supposed to be the most portable. The "not portable" API is called the "Public API".

For me, the reference documentation about that is now:https://devguide.python.org/developer-workflow/c-api/index.html#changing-python-s-c-api

See also:Include/README.rst.

* implementing custom frame evaluators with PEP 523. */

/* Returns the code object of the frame.
* Does not raise an exception. */
Copy link
Member

Choose a reason for hiding this comment

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

Somewhere I saw the expression: "This function cannot fail" but I can no longer find it in the doc.

markshannonand others added3 commitsSeptember 15, 2022 17:02
…IS.rstCo-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
@smontanaro
Copy link
Contributor

(I'm working my way through some PRs which have been approved and are labeled "awaiting merge", hence my seemingly bolt from the blue comment. Why?Read here.)

This PR has been idle for awhile. Can it be merged or is there more to do?

@iritkatriel
Copy link
Member

Is this supposed to be in 3.12?

@markshannon
Copy link
MemberAuthor

We might as well. I'm unsure how people use PEP 523, but this should help.

I'll add theUnstable prefix to them now that PEP 689 has been accepted.

@markshannonmarkshannonforce-pushed thepy-interpreter-frame-api branch 2 times, most recently from67a5450 to7fbece8CompareMay 5, 2023 16:23
@markshannonmarkshannon merged commita0df9ee intopython:mainMay 5, 2023
carljm added a commit to carljm/cpython that referenced this pull requestMay 5, 2023
* main:pythongh-99113: Add PyInterpreterConfig.own_gil (pythongh-104204)pythongh-104146: Remove unused var 'parser_body_declarations' from clinic.py (python#104214)pythongh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (pythongh-104205)pythongh-104108: Add the Py_mod_multiple_interpreters Module Def Slot (pythongh-104148)pythongh-99113: Share the GIL via PyInterpreterState.ceval.gil (pythongh-104203)pythonGH-100479: Add `pathlib.PurePath.with_segments()` (pythonGH-103975)pythongh-69152: Add _proxy_response_headers attribute to HTTPConnection (python#26152)pythongh-103533: Use PEP 669 APIs for cprofile (pythonGH-103534)pythonGH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque for users of PEP 523. (pythonGH-96849)
jbower-fb pushed a commit to jbower-fb/cpython that referenced this pull requestMay 8, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vstinnervstinnervstinner left review comments

@pablogsalpablogsalpablogsal approved these changes

@carljmcarljmcarljm approved these changes

@iritkatrieliritkatrielAwaiting requested review from iritkatriel

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

7 participants
@markshannon@smontanaro@iritkatriel@carljm@vstinner@pablogsal@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp