Skip to content
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

bpo-29916: Include PyGetSetDef in C API extension documentation #831

Merged
merged 3 commits into from
Sep 15, 2017
Merged

bpo-29916: Include PyGetSetDef in C API extension documentation #831

merged 3 commits into from
Sep 15, 2017

Conversation

MSeifert04
Copy link
Contributor

@MSeifert04 MSeifert04 commented Mar 27, 2017

There is currently only indirect documentation of the PyGetSetDef struct in the documentation in the PyTypeObject.tp_getset slot. However the documentation there contains a note that it "belongs elsewhere".

The rendered documentation looks like this:

unbenannt

https://bugs.python.org/issue29916

@mention-bot
Copy link

@MSeifert04, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @ashemedai and @vadmium to be potential reviewers.

@serhiy-storchaka
Copy link
Member

Please open an issue on the bug tracker.

@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Mar 27, 2017

Please open an issue on the bug tracker.

done

+-------------+------------------+-----------------------------------+
| Field | C Type | Meaning |
+=============+==================+===================================+
| name | char \* | attribute name. |
Copy link
Member

Choose a reason for hiding this comment

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

const char \*

See #846.

+-------------+------------------+-----------------------------------+


.. c:type:: getter
Copy link
Member

Choose a reason for hiding this comment

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

Are any other names without the "Py" prefix documented? If are not, I would prefer to not document getter and setter explicitly.

Copy link
Contributor Author

@MSeifert04 MSeifert04 Mar 27, 2017

Choose a reason for hiding this comment

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

There are several definitions METH_VARARGS, etc. without the Py_-prefix. I just "copied" that "style".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You decide, drop or keep? And if dropped should the explanation stay or be deleted as well?

Copy link
Member

Choose a reason for hiding this comment

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

I have opened a thread on Python-Dev. If the decision will be to add Py-prefixed aliases, they can be documented as common types. Otherwise I would prefer to not document them explicitly (as well as a number of other typedefs in typeobj.rst).

typedef int (*setter)(PyObject *, PyObject *, void *);

In case the attribute should be deleted the second parameter is *NULL*.
Should return 0 on success or -1 with a set exception on failure.
Copy link
Member

Choose a reason for hiding this comment

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

Format return codes as ``0`` and ``-1``.

@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Mar 27, 2017

I removed the getter and setter documentation. The disussion on python-dev is still pending, but a consensus would require significantly more documentation additions (so out of scope for this PR).

The updated documentation (preview) looks like this:

unbenannt

@brettcannon brettcannon added the docs Documentation in the Doc dir label Mar 27, 2017
@brettcannon
Copy link
Member

@MSeifert04 Could you add the issue number to the title of your PR? E.g. "bpo-1234: include ...".

@MSeifert04 MSeifert04 changed the title include PyGetSetDef in C API extension documentation. bpo-29916: Include PyGetSetDef in C API extension documentation. Mar 27, 2017
@serhiy-storchaka
Copy link
Member

@brettcannon, you can edit the title yourself.

@MSeifert04
Copy link
Contributor Author

done

@brettcannon
Copy link
Member

@serhiy-storchaka I know, but no comment was left here in the PR of what the actual issue number was, so it was just as easy to ask @MSeifert04 to add the issue number instead of ask for the number and then me manually adding the number (especially if @MSeifert04 contributes again in the future).

@MSeifert04
Copy link
Contributor Author

FYI: The first commit did contain the issue number. But I forgot to change the title after changing the commit message :)

@MSeifert04
Copy link
Contributor Author

Anything I can do here? Or do I just wait for someone to review (proofread) it?

@serhiy-storchaka
Copy link
Member

Just wait until we decide what to do with names like getter and setter. If we decide to add Py-aliases, your original patch can be restored (with new names).

@MSeifert04
Copy link
Contributor Author

I just noticed that several of these typedefs are documented: visitproc, traverseproc, and inquiry. So getter and setter wouldn't be the first documented not-Py* definitions.

@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Jul 18, 2017

There haven't been any new answers to the python-dev thread. Does that mean the PR is essentially declined or just on hold?

@brettcannon brettcannon reopened this Jul 19, 2017
@brettcannon brettcannon changed the title bpo-29916: Include PyGetSetDef in C API extension documentation. bpo-29916: Include PyGetSetDef in C API extension documentation Jul 19, 2017
@brettcannon
Copy link
Member

Part of the delay at this point is last week a discussion started about trying to clean up the C API. But I think at this point we probably don't need to wait for prefixing since if we start cleaning up things we will add the aliases then. What do you think @serhiy-storchaka ?

And please ignore the opening/closing as that was just an attempt to trigger the issue number status check.

@serhiy-storchaka
Copy link
Member

I don't know. I asked on Python-Dev but didn't get an answer.

@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Sep 15, 2017

So this will just stay open/unmerged until a consensus (on a topic nobody is discussing) is reached?

I thought this PR was just a minor documentation improvement but I don't like the fact that it has completely stalled. If there's no interest in this I'll gladly close the PR and move on...

+-------------+------------------+-----------------------------------+
| Field | C Type | Meaning |
+=============+==================+===================================+
| name | const char \* | attribute name. |
Copy link
Member

Choose a reason for hiding this comment

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

If the description ends with a period, it should starts with an upper case. But descriptions in other tables don't start with an upper case and don't contain periods. Please make the style of this table matching the style of other tables.

The only problem is with the set description, which consists of two sentences. I think you can use a semicolon for separating two parts.

The ``get`` function takes one :c:type:`PyObject\*` parameter (the
instance) and a function pointer (the associated ``closure``)::

typedef PyObject *(*getter)(PyObject *, void *);
Copy link
Member

Choose a reason for hiding this comment

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

Please remove one space before typedef. Three-space indentation is used in this file.

@serhiy-storchaka
Copy link
Member

Thank you for a reminder and sorry for the delay. Your change definitely is an improvement. We can change the documentation for getter and setter in other issue.

LGTM, except two nitpicks.

@MSeifert04
Copy link
Contributor Author

Thanks for the review. I changed it accordingly.

There is a failure due to a missing news item or missing label. I assume this doesn't warrant a news-item so I think the label should be attached but let me know if I need to add a news-entry.

@serhiy-storchaka serhiy-storchaka merged commit da67e0d into python:master Sep 15, 2017
@miss-islington
Copy link
Contributor

Thanks @MSeifert04 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6.
🐍🍒⛏🤖

@MSeifert04 MSeifert04 deleted the missing_pygetsetdef_documentation branch September 15, 2017 16:28
@miss-islington
Copy link
Contributor

Thanks @MSeifert04 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

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

@bedevere-bot
Copy link

GH-3607 is a backport of this pull request to the 3.6 branch.

@miss-islington
Copy link
Contributor

Thanks @MSeifert04 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

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

@bedevere-bot
Copy link

GH-3609 is a backport of this pull request to the 2.7 branch.

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.

8 participants