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-115653: Add docs for the PyCode_GetFirstFree and correct return type for the PyCode_GetNumFree#115654

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
vstinner merged 4 commits intopython:mainfromwrongnull:patch-3
Feb 21, 2024

Conversation

wrongnull
Copy link
Contributor

@wrongnullwrongnull commentedFeb 19, 2024
edited by github-actionsbot
Loading

andiserg reacted with thumbs up emoji
@wrongnullwrongnull changed the titlegh-115653: Add docs for the PyCode_GetFirstFree and correct return type for the PyCode_GetFirstFreegh-115653: Add docs for the PyCode_GetFirstFree and correct return type for the PyCode_GetNumFreeFeb 19, 2024
@Eclips4Eclips4 added the needs backport to 3.12only security fixes labelFeb 19, 2024
@wrongnull
Copy link
ContributorAuthor

wrongnull commentedFeb 20, 2024
edited
Loading

BTW, shouldPyCode_GetFirstFree cast the return value toPy_ssize_t? As I can see this function is used mostly for calculating offsets.


Return the number of free variables in *co*.

.. c:function:: int PyCode_GetFirstFree(PyCodeObject *co)

Return the number of local + cell variables in *co*.
Copy link
Contributor

Choose a reason for hiding this comment

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

Document what the API does, not its implementation details:PyCode_GetFirstFree returns the position (or offset) of the first free variable inco.

FTR:@markshannon and@iritkatriel introduced this API ingh-100721. It is available via Python.h.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done. But my question above still stands. If I'm right I might make a separate pull request for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

See the PR I linked to, especially#100721 (comment) and49ca044.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thank you. If there is anything else here that I could fix, I'll be happy to do it.

erlend-aasland reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

I would still like to hear from either@markshannon or@iritkatriel; I'm not sure this was intended as a public API.

wrongnull reacted with eyes emoji
Copy link
Member

@markshannonmarkshannonFeb 21, 2024
edited
Loading

Choose a reason for hiding this comment

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

It was and it wasn't. We don't really want to expose it, but if we don't then Cython and other C extensions will access the internal fields directly, which is worse.

Now that we have an unstable API, it should probably be part of that.
I'd like all code object C APIs to be unstable, but it's probably too late for that.

Maybe rename it toPyUnstableCode_GetFirstFree?

erlend-aasland and wrongnull reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename it to PyUnstableCode_GetFirstFree?

Sounds like a good idea, but since it is already included in 3.12, we have to deprecatePyCode_GetFirstFree andPyUnstableCode_GetFirstFree in 3.13.

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow-up issue:#115756.

@erlend-aasland
Copy link
Contributor

In general, please split up multiple changes in atomic PRs; the distinct changes might not have equal backport requirements. For these two changes it looks to me both of them are applicable for a 3.12 backport only, so you're fine.

wrongnull reacted with thumbs up emoji

@@ -30,10 +30,14 @@ bound into a function.
Return true if *co* is a :ref:`code object <code-objects>`.
This function always succeeds.

.. c:function::int PyCode_GetNumFree(PyCodeObject *co)
.. c:function::Py_ssize_t PyCode_GetNumFree(PyCodeObject *co)

Return the number of free variables in *co*.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Return the number of free variables in*co*.
Return the number of free variables ina code object.


Return the number of free variables in *co*.

.. c:function:: int PyCode_GetFirstFree(PyCodeObject *co)

Return the position of first free variable in *co*.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Return the position of first free variable in*co*.
Return the position ofthefirst free variable ina code object.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

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.

LGTM.

wrongnull reacted with heart emoji
@miss-islington-app
Copy link

Thanks@wrongnull for the PR, and@vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 21, 2024
Correct the return type of the PyCode_GetNumFree() documentation.(cherry picked from commit10fc467)Co-authored-by: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com>
@bedevere-app
Copy link

GH-115752 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelFeb 21, 2024

Return the number of free variables in *co*.
Return the number of free variables in a code object.
Copy link
Contributor

Choose a reason for hiding this comment

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

@vstinner, I think this is the suggested style:

Suggested change
Return the number of free variables inacode object.
Return the number of free variables in code object *co*.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I just merged the change. Is it worth it to change the style, or is it ok to merge PRgh-115752 backport? I let you decide :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it's not worth it to change the style, but I think we should try to keep it in mind for next time ;)

Eclips4 reacted with thumbs up emoji
@wrongnullwrongnull deleted the patch-3 branchFebruary 21, 2024 10:30
vstinner pushed a commit that referenced this pull requestFeb 21, 2024
gh-115653: Document PyCode_GetFirstFree() (GH-115654)Correct the return type of the PyCode_GetNumFree() documentation.(cherry picked from commit10fc467)Co-authored-by: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com>
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull requestMar 4, 2024
Correct the return type of the PyCode_GetNumFree() documentation.
diegorusso pushed a commit to diegorusso/cpython that referenced this pull requestApr 17, 2024
Correct the return type of the PyCode_GetNumFree() documentation.
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull requestJan 22, 2025
Correct the return type of the PyCode_GetNumFree() documentation.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vstinnervstinnervstinner approved these changes

@markshannonmarkshannonmarkshannon left review comments

@erlend-aaslanderlend-aaslanderlend-aasland left review comments

@Eclips4Eclips4Eclips4 left review comments

Assignees
No one assigned
Labels
docsDocumentation in the Doc dirskip news
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@wrongnull@erlend-aasland@vstinner@markshannon@Eclips4

[8]ページ先頭

©2009-2025 Movatter.jp