◐ Shell
reader mode source ↗
Skip to content

DOC: emphasize the need to always call PySequence_Fast#11140

Merged
benjaminp merged 5 commits into
python:masterfrom
mattip:pysequence_fast-pypy
Sep 12, 2019
Merged

DOC: emphasize the need to always call PySequence_Fast#11140
benjaminp merged 5 commits into
python:masterfrom
mattip:pysequence_fast-pypy

Conversation

@mattip

@mattip mattip commented Dec 13, 2018

Copy link
Copy Markdown
Contributor

PySequence_Fast() should always be used (and the result checked) before any of the other PySequence_Fast* family of functions. As an implementation detail, CPython can circumvent this if PyTuple_CheckExact() passes, but that does not work on PyPy.

xref numpy/numpy#12524

@serhiy-storchaka

Copy link
Copy Markdown
Member

Is not this a PyPy issue that PySequence_Fast* functions do not work with lists and tuples?

@mattip

mattip commented Dec 13, 2018

Copy link
Copy Markdown
Contributor Author

The functions work for ret after calling PyObject* ret = PySequence_Fast(o), on both PyPy and CPython, but the documentation was not clear that this is always necessary. Hopefully now it is clearer.

@eric-wieser

Copy link
Copy Markdown
Contributor

@serhiy-storchaka: I think the point is that requiring those functions to work on lists and tuples puts nasty lifetime constraints on pypy, which could be lifted simply by relaxing the documentation to saying "PySequence_Fast_ITEMS is only defined on the result of PySequence_Fast".

@serhiy-storchaka

Copy link
Copy Markdown
Member

I think this change needs more wide discussion. Please open an issue on the bug tracker and ask the question on the Python-Dev mailing list.

@JulienPalard

Copy link
Copy Markdown
Member

@mattip Hi, have you been able to open an issue on bugs.python.org about it as requested by Serhiy?

@mattip

mattip commented Sep 11, 2019

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka what do you see as controversial? Perhaps you could suggest a phrasing that would not require such an extensive discussion for a documentation clarification?

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@mattip

mattip commented Sep 12, 2019

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@benjaminp: please review the changes made to this pull request.

@mattip

mattip commented Sep 12, 2019

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@benjaminp: please review the changes made to this pull request.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @mattip for the PR, and @benjaminp for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.7, 3.8.
🐍🍒⛏🤖

@bedevere-bot bedevere-bot removed the label Sep 12, 2019
@bedevere-bot

Copy link
Copy Markdown

GH-16068 is a backport of this pull request to the 3.8 branch.

@bedevere-bot

Copy link
Copy Markdown

GH-16069 is a backport of this pull request to the 3.7 branch.

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @mattip and @benjaminp, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 57b7dbc46e71269d855e644d30826d33eedee2a1 2.7

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 12, 2019
(cherry picked from commit 57b7dbc)

Co-authored-by: Matti Picus <matti.picus@gmail.com>
miss-islington added a commit that referenced this pull request Sep 12, 2019
(cherry picked from commit 57b7dbc)

Co-authored-by: Matti Picus <matti.picus@gmail.com>
miss-islington added a commit that referenced this pull request Sep 12, 2019
(cherry picked from commit 57b7dbc)

Co-authored-by: Matti Picus <matti.picus@gmail.com>
gpshead added a commit to gpshead/cpython that referenced this pull request Feb 12, 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 issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants