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

Add guidelines for changing/removing from the Limited API #778

Merged
merged 4 commits into from Dec 14, 2021

Conversation

encukou
Copy link
Member

@encukou encukou commented Dec 7, 2021

c-api.rst Outdated
Comment on lines 133 to 134
.. _macro: https://github.com/python/cpython/blob/3.10/Objects/object.c#L2298-L2308
.. _redefinition: https://github.com/python/cpython/blob/main/Include/object.h#L603-L606
Copy link
Member

Choose a reason for hiding this comment

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

Is it safe to refer lines in branches instead of tags and commits? For example, Py_NewRef shifted up by 56 lines after it was redefined.

Suggested change
.. _macro: https://github.com/python/cpython/blob/3.10/Objects/object.c#L2298-L2308
.. _redefinition: https://github.com/python/cpython/blob/main/Include/object.h#L603-L606
.. _macro: https://github.com/python/cpython/blob/v3.10.1/Objects/object.c#L2299-L2307
.. _redefinition: https://github.com/python/cpython/blob/53a03aa/Include/object.h#L547-L550

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that! I failed to copy/paste the right URL.

- the Backwards Compatibility Policy (:pep:`387`) is followed, and
- the Stable ABI is not broken -- that is, extensions compiled with
Limited API of older versions of Python continue to work on
newer versions of Python.
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to export a function which always fail, if the function has been removed? Removing PyUnicode_InternImmortal() sounds like an interesting challenge: https://bugs.python.org/issue41692

Maybe the function can be replaced with a function... which does nothing but log an error?

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to export a function which always fail, if the function has been removed?

I believe, only if the function is not vital for already compiled modules (so its failure won't hamper their main activity). That's actually the whole point of backwards compatibility, to not break third party things that already work.

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO, after it's removed from the API and when SSTATE_INTERNED_IMMORTAL needs to be removed, PyUnicode_InternImmortal can do an unpaired INCREF: make the string immortal, but leak it.
See https://www.python.org/dev/peps/pep-0652/#stable-abi:

Future Python versions may deprecate some members of the Stable ABI. Deprecated members will still work, but may suffer from issues like reduced performance or, in the most extreme cases, memory/resource leaks.

c-api.rst Outdated
its size must not change.
- Exported symbols (functions and data) must continue to be available
as exported symbols. Specifically, a function can only be converted
to a `static inline` function (or macro) if Python also continues to
Copy link
Member

Choose a reason for hiding this comment

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

More backticks?

@encukou encukou merged commit 5c8a021 into python:main Dec 14, 2021
@encukou encukou deleted the c-api branch December 14, 2021 13:53
@encukou
Copy link
Member Author

encukou commented Dec 14, 2021

Thanks for the reviews!

If you have any more questions, let me know! I thought I left breadcrumbs in all the right places, but I see people coming from directions that are only obvious in retrospect :)

AA-Turner pushed a commit to AA-Turner/devguide that referenced this pull request Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants