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-101100: Clean up Doc/c-api/exceptions.rst and Doc/c-api/sys.rst#114825

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
serhiy-storchaka merged 11 commits intopython:mainfromsmontanaro:doc-capi
Feb 11, 2024

Conversation

smontanaro
Copy link
Contributor

@smontanarosmontanaro commentedJan 31, 2024
edited by github-actionsbot
Loading

This PR cleans up several bits inDoc/c-api/exceptions.rst:

  • suppress link towarnings.WarningMessage. It's not actually documented and isn't exposed bywarnings.__all__. It's just a basic exception carrying around a message.
  • suppress link for__module__ attribute. The good stuff is in the containing paragraph.
  • suppress link forUSE_STACKCHECK. The good stuff is in the documentation ofPyOS_CheckStack, which is linked from the containing paragraph.
  • suppress links for three aliases forPyExc_OSError.

Since I was hunting downUSE_STACKCHECK, I went ahead and suppressed the reference inDoc/c-api/sys.rst, in the documentation forPyOS_CheckStack.

I updatedDoc/tools/.nitignore to removeDoc/c-api/exceptions.rst, but left an entry forDoc/c-api/sys.rst, as I didn't make an attempt to address any other problems it might have.


📚 Documentation preview 📚:https://cpython-previews--114825.org.readthedocs.build/

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

If you want to specify their declaration, you can simply use typedef-like syntax.

I would move thePy_AuditHookFunction definition directly intoPySys_AddAuditHook definition where it is only used. You need to add.. c:namespace:: NULL before it to avoid adding a prefix.

ThePyOS_sighandler_t definition can be moved closer toPyOS_getsig() orPyOS_setsig() definitions. Duplicated description ofPyOS_sighandler_t can be removed.

@smontanaro
Copy link
ContributorAuthor

Thanks@serhiy-storchaka, I believe I folded in your suggestions in a reasonable way.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

It deviated significantly from initial "clean up Doc/c-api/exceptions.rst", isn't? 😉 Maybe split it on several PRs? The auditing part is not trivial.

LGTM after you do something with duplication forPy_AuditHookFunction. For example:

   ..c:namespace::NULL   ..c:type::int (*Py_AuditHookFunction) (constchar *event, PyObject   *args, void *userData)      The type of the hook function.      *event* is (the event argument passed to PySys_Audit() or PySys_AuditTuple()),      *args* is (...), *userData* is (the argument passed to PySys_AddAuditHook()).      The hook function is always called ...   See:pep:`578` for ...

@smontanaro
Copy link
ContributorAuthor

Feature creep is no problem. I'm retired, so have plenty of time to mess around. ;-)

Since it seems like I might have to write an actual sentence to flesh out this paragraph, I'm going to spend a bit of time reading PEP 578, but I'll have something later today.

.. c:type:: int (*Py_AuditHookFunction) (const char *event, PyObject *args, void *userData)

The type of the hook function.
*event* is (the event argument passed to PySys_Audit() or PySys_AuditTuple()),

Choose a reason for hiding this comment

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

Wait, I used parentheses to denote that it is a preliminary text, and that you should rewrite it in good English. Perhaps it is even better to describe parameters not in terms of PySys_Audit() or PySys_AuditTuple(), but in more general terms. Look atsys.audit(). Perhaps "event is a C string identifying the event" is enough.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ah, I recognized "(...)" as a placeholder, not the more elaborate parenthesized phrasing. Will get back to it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Perhaps "event is a C string identifying the event" is enough.

I thought about that, but am not familiar enough with the C API documentation to know that descriptions of function prototypes don't simply rely on the actual prototype.

Comment on lines 367 to 368
.. c:namespace:: NULL
.. c:type:: int (*Py_AuditHookFunction) (const char *event, PyObject *args, void *userData)

Choose a reason for hiding this comment

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

If it is not nested,c:namespace is not needed. I would prefer to make it nested, but it is only my personal preference.

Comment on lines 359 to 363
If the interpreter is initialized, this function raisesan auditing event
``sys.addaudithook`` with no arguments. If any existing hooks raise an
exception derived from :class:`Exception`, the new hook will not be
added and the exception is cleared. As a result, callers cannot assume
that their hook has been added unless they control all existing hooks.

Choose a reason for hiding this comment

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

Why is it dedented? It belongs to theaudit-event directive.

@smontanaro
Copy link
ContributorAuthor

Sorry, I clearly don't understand the functional implications of the indentation. See if this latest version is more correct.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@serhiy-storchakaserhiy-storchakaenabled auto-merge (squash)February 11, 2024 18:45
@serhiy-storchakaserhiy-storchaka added needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsFeb 11, 2024
@serhiy-storchakaserhiy-storchaka changed the titlegh-101100: clean up Doc/c-api/exceptions.rstgh-101100: Clean up Doc/c-api/exceptions.rst and Doc/c-api/sys.rstFeb 11, 2024
@serhiy-storchakaserhiy-storchaka merged commite1552fd intopython:mainFeb 11, 2024
@miss-islington-app
Copy link

Thanks@smontanaro for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 11, 2024
…rst (pythonGH-114825)(cherry picked from commite1552fd)Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
@miss-islington-app
Copy link

Sorry,@smontanaro and@serhiy-storchaka, I could not cleanly backport this to3.11 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker e1552fd19de17e7a6daa3c2a6d1ca207bb8eaf8e 3.11

@bedevere-app
Copy link

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

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelFeb 11, 2024
@smontanarosmontanaro deleted the doc-capi branchFebruary 11, 2024 18:57
serhiy-storchaka pushed a commit that referenced this pull requestFeb 11, 2024
….rst (GH-114825) (GH-115308)(cherry picked from commite1552fd)Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
@smontanaro
Copy link
ContributorAuthor

@serhiy-storchaka I'll take care of the 3.11 conflict (I need the practice).

@bedevere-app
Copy link

GH-115311 is a backport of this pull request to the3.11 branch.

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

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

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

Successfully merging this pull request may close these issues.

2 participants
@smontanaro@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp