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-45474: Fix the limited C API of marshal.h #28956

Merged
merged 1 commit into from Oct 14, 2021
Merged

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 14, 2021

Remove two functions from the limited C API:

  • PyMarshal_WriteLongToFile()
  • PyMarshal_WriteObjectToFile()

The PEP 384 excludes functions expecting "FILE*" from the stable ABI.

Remove also the Py_MARSHAL_VERSION macro from the limited C API.

https://bugs.python.org/issue45474

Remove two functions from the limited C API:

* PyMarshal_WriteLongToFile()
* PyMarshal_WriteObjectToFile()

The PEP 384 excludes functions expecting "FILE*" from the stable ABI.

Remove also the Py_MARSHAL_VERSION macro from the limited C API.
@vstinner
Copy link
Member Author

vstinner commented Oct 14, 2021

cc @encukou

@vstinner
Copy link
Member Author

vstinner commented Oct 14, 2021

Functions documented at:

Note: even if PyMarshal_ReadObjectFromString() and PyMarshal_WriteObjectToString() are listed in Misc/stable_abi.txt, it's not mentioned in the documentation that they are part of the stable ABI. I don't know if it is a deliberate choice or not. Misc/stable_abi.txt contains a comment:

# The following are defined in private headers, but historically
# they were exported as part of the stable ABI.
function PyMarshal_ReadObjectFromString
    added 3.2
    abi_only
function PyMarshal_WriteObjectToString
    added 3.2
    abi_only

@vstinner
Copy link
Member Author

vstinner commented Oct 14, 2021

If PyMarshal_ReadObjectFromString() is only part of the stable API but not part of the limited C API, the current mashal.h is wrong, no?

@vstinner vstinner merged commit af1083e into python:main Oct 14, 2021
12 checks passed
@vstinner vstinner deleted the marshal_h branch Oct 14, 2021
@vstinner
Copy link
Member Author

vstinner commented Oct 14, 2021

I'm trying to remove #include <stdio.h> from Python.h if Py_LIMITED_API is defined. marshal.h prevented me to do that, so I merged my change.

See: https://bugs.python.org/issue45434

@encukou
Copy link
Member

encukou commented Oct 15, 2021

The PyMarshal_*String are now defined in a private header, so they're effectively not part of the limited API.
But if they were in public headers in 3.3, the symbols need to remain part of the stable ABI.

Since marshal.h is not included in <Python.h> I don't think it necessarily needs the Py_LIMITED_API guard.
But it would be nice to be explicit and add them – to the whole file.

ShivnarenSrinivasan pushed a commit to ShivnarenSrinivasan/cpython that referenced this pull request Oct 15, 2021
Remove two functions from the limited C API:

* PyMarshal_WriteLongToFile()
* PyMarshal_WriteObjectToFile()

The PEP 384 excludes functions expecting "FILE*" from the stable ABI.

Remove also the Py_MARSHAL_VERSION macro from the limited C API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants