-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-5945: mapping.rst: PyMapping_Check(list) returns 1 #144
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow these steps to help rectify the issue:
Thanks again to your contribution and we look forward to looking at it! |
Doc/c-api/mapping.rst
Outdated
@@ -9,7 +9,8 @@ Mapping Protocol | |||
.. c:function:: int PyMapping_Check(PyObject *o) | |||
|
|||
Return ``1`` if the object provides mapping protocol, and ``0`` otherwise. This | |||
function always succeeds. | |||
function always succeeds. This is not exactly equivalent to ``collections.abc.Mapping``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double space after sentence-ending period. The line is too long, wrap it at column 79. Make collections.abc.Mapping a reference.
Should the commit rebase into one commit? |
@grapherd The PR can be accepted as a squash merge in one click that will have the same effect as manually squashing it. |
As discussed below, in Python 3, PyMapping_Check(list) returns 1. This behavior is justified by a developer as consistent with Python 3's internals. It is however surprising to C-API users (speaking from experience) and because it deviates from collections.abc.Mapping. https://mail.python.org/pipermail/python-dev/2009-May/089445.html Squashed a few revisions
e9ad4cc
to
0c7abc1
Compare
Rebased to HEAD and squashed |
I think this looks good now. @serhiy-storchaka would you like to take another look? I can do the backports. |
No backports please. |
This is just the documentation fix. I think it should be backported. But proposed wording doesn't LGTM. See my comment on the tracker. |
On bpo serhiy-storchaka wrote:
There is no recommendation to use
So I think it is appropriate to keep the proposed wording since it steers users to ABC checks and away from these APIs. If there is a change perhaps it should be explicitly "not recommended" in the documentation. |
…iew_new Replace copied code by a limited API function. This fixes the assertion error caused by commit 2eea952.
Stackless contributes two tests to builtins: TaskletExit and TaskletExit.__init__. Therefore we have to adjust the limit. Add missing changelog entries (python#143, python#144).
To try and help move older pull requests forward, we are going through and backfilling 'awaiting' labels on pull requests that are lacking the label. Based on the current reviews, the best we can tell in an automated fashion is that a core developer requested changes to be made to this pull request. If/when the requested changes have been made, please leave a comment that says, |
I have made the requested changes; please review again. Given that several core developers suggested or concurred with deprecating this API (Benjamin Peterson, GvR, Raymond Hettinger) I marked it not recommended as an alternative to officially deprecating. I think it is best to omit the suggestion to use |
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
Stackless contributes two tests to builtins: TaskletExit and TaskletExit.__init__. Therefore we have to adjust the limit. Add missing changelog entries (python#143, python#144). (cherry picked from commit 7327e4b)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbarlow83 Thanks for the PR and the changes. To keep this PR from further languishing, I suppose it may be most efficient to update the wording to incorporate @serhiy-storchaka's suggestion.
Doc/c-api/mapping.rst
Outdated
Return ``1`` if the object provides mapping protocol, and ``0`` otherwise. This | ||
function always succeeds. | ||
**Not recommended.** Return ``1`` if the object provides the C-API mapping | ||
protocol, and ``0`` otherwise. This function always succeeds. The C-API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using @serhiy-storchaka's suggested wording to move this PR forward.
The C-API mapping protocol is not equivalent to :class:collections.abc.Mapping
, and also returns 1
for sequences that support slicing. Use :c:func::PyObject_IsInstance
instead.
PyMapping_Check() also returns 1 for sequences that support slicing.
@willingc Done |
Thanks @jbarlow83 for the quick response. @serhiy-storchaka This looks good to me now. If you have no further changes, I recommend merging. Thanks. |
Superseded by #7029 |
As discussed below, in Python 3, PyMapping_Check(list) returns 1. This behavior is justified by a developer as consistent with Python 3's internals. It is however surprising to C-API users (speaking from experience) and because it deviates from collections.abc.Mapping.
I think it is better to be vague than describe the implementation details.
https://mail.python.org/pipermail/python-dev/2009-May/089445.html
https://bugs.python.org/issue5945