Skip to content

gh-115172: Fix explicit index extries for the C API #115173

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Feb 8, 2024

@serhiy-storchaka serhiy-storchaka added docs Documentation in the Doc dir skip news needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Feb 8, 2024
@serhiy-storchaka
Copy link
Member Author

@smontanaro, could you please look at it?

@smontanaro
Copy link
Contributor

smontanaro commented Feb 8, 2024

@serhiy-storchaka I've added your fork as an(other) upstream and have your docs-index branch checked out.

Edit: ignore this:

~~Am I correct in understanding all your index:: edits were done manually? There's no Sphinx support for these enhancements or for generating these index entries as a side effect of using other directives? Using a concrete example:

.. index:: single: PyBufferProcs (C type)

Two questions:

  1. Is there a c:type PyBufferProcs directive which would have implicitly done this?
  2. Is there a general translation between <domain>:<name> <Something> and .. index:: single: <Something> (<domain> <name>)~~

(In retrospect, I think my comment was pretty much worthless. It turns out that strikethrough markup doesn't seem to be supported here...)

single: T_STRING
single: T_STRING_INPLACE
single: T_OBJECT_EX
single: T_BYTE (C macro)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't all of these have a Py_ prefix?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are legacy names, which require including <structmembers.h>. There are also aliases with the Py_ prefix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. Again, it would be nice to have some way to identify them as legacy/deprecated/discouraged names.

single: READ_RESTRICTED
single: WRITE_RESTRICTED
single: RESTRICTED
single: READ_RESTRICTED (C macro)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering... would it make sense to indicate in the index that these *_RESTRICTED macros are deprecated? For example:

   single: READ_RESTRICTED (deprecated C macro)
   single: WRITE_RESTRICTED (deprecated C macro)
   single: RESTRICTED (deprecated C macro)

If so, this might well be applied in many other places.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we add

.. c:macro:: READ_RESTRICTED

it will add index entry for "READ_RESTRICTED (C macro)". No way to add "deprecated" here (unless we write our own Sphinx extensions). And some of deprecated names are declared in such way, so we will have inconsistency,

Also, I think that an index entry is just an index entry. It contains the name and maybe some qualifier to distinguish it from the same name in other namespaces. But there is no non-deprecated C macro with the same name.

Copy link
Contributor

Choose a reason for hiding this comment

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

These index entries were added manually, right? Can't they just be edited right where they sit? That way, the word "deprecated" will be part of the index entry, subtly discouraging people from using them in their (new) code. I wasn't thinking of adding a c:macro directive.

Copy link
Member Author

Choose a reason for hiding this comment

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

But if we have two deprecated names, and one of them is declared with with the c:macro directive, the index entries will be:

BAR (C macro)
BAZ (deprecated C macro)

Both names are deprecated, but only one of them has an index entry that says this. Would not it confuse users?

I think that the index is not a right place for this. It is just an index, and you have to click the link to get the information.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine. Was just tossing the idea out there.

@serhiy-storchaka
Copy link
Member Author

PyBufferProcs is already defined as .. c:type:: PyBufferProcs in other place. As well as many other names. It just hapenns that there is a separate index entry for PyBufferProcs, but it created a different index entry, instead of adding yet one link for the same entry, because it lacked the " (C type)" suffix.

@serhiy-storchaka serhiy-storchaka merged commit 573acb3 into python:main Feb 11, 2024
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the docs-index branch February 11, 2024 10:23
@miss-islington-app
Copy link

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 573acb30f22a84c0f2c951efa002c9946e29b6a3 3.12

@miss-islington-app
Copy link

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 573acb30f22a84c0f2c951efa002c9946e29b6a3 3.11

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Feb 11, 2024
@bedevere-app
Copy link

bedevere-app bot commented Feb 11, 2024

GH-115292 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 11, 2024
serhiy-storchaka added a commit that referenced this pull request Feb 11, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Feb 11, 2024
@bedevere-app
Copy link

bedevere-app bot commented Feb 11, 2024

GH-115293 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Feb 11, 2024
serhiy-storchaka added a commit that referenced this pull request Feb 11, 2024
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants