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

gh-112026: Restore removed private C API #112115

Merged
merged 1 commit into from Nov 15, 2023

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Nov 15, 2023

Restore removed private C API functions, macros and structures which have no simple replacement for now:

  • _PyDict_GetItem_KnownHash()
  • _PyDict_NewPresized()
  • _PyHASH_BITS
  • _PyHASH_IMAG
  • _PyHASH_INF
  • _PyHASH_MODULUS
  • _PyHASH_MULTIPLIER
  • _PyLong_Copy()
  • _PyLong_FromDigits()
  • _PyLong_New()
  • _PyLong_Sign()
  • _PyObject_CallMethodId()
  • _PyObject_CallMethodNoArgs()
  • _PyObject_CallMethodOneArg()
  • _PyObject_CallOneArg()
  • _PyObject_EXTRA_INIT
  • _PyObject_FastCallDict()
  • _PyObject_GetAttrId()
  • _PyObject_Vectorcall()
  • _PyObject_VectorcallMethod()
  • _PyStack_AsDict()
  • _PyThread_CurrentFrames()
  • _PyUnicodeWriter structure
  • _PyUnicodeWriter_Dealloc()
  • _PyUnicodeWriter_Finish()
  • _PyUnicodeWriter_Init()
  • _PyUnicodeWriter_Prepare()
  • _PyUnicodeWriter_PrepareKind()
  • _PyUnicodeWriter_WriteASCIIString()
  • _PyUnicodeWriter_WriteChar()
  • _PyUnicodeWriter_WriteLatin1String()
  • _PyUnicodeWriter_WriteStr()
  • _PyUnicodeWriter_WriteSubstring()
  • _PyUnicode_AsString()
  • _PyUnicode_FromId()
  • _PyVectorcall_Function()
  • _Py_IDENTIFIER()
  • _Py_c_abs()
  • _Py_c_diff()
  • _Py_c_neg()
  • _Py_c_pow()
  • _Py_c_prod()
  • _Py_c_quot()
  • _Py_c_sum()
  • _Py_static_string()
  • _Py_static_string_init()

@vstinner
Copy link
Member Author

Last weeks, other functions removed in Python 3.13 were reported as causing problems.

The following functions were already restored since Python 3.13 alpha1:

  • _PyLong_AsByteArray()
  • _PyLong_FromByteArray()

Not restored, use new public functions instead:

  • _PyObject_VisitManagedDict(): use PyObject_VisitManagedDict()
  • _PyObject_ClearManagedDict(): use PyObject_ClearManagedDict()
  • _PyThreadState_UncheckedGet(): use PyThreadState_GetUnchecked()
  • _PyList_Extend(): use PyList_Extend(), different API
  • _PyDict_Pop(): use PyDict_Pop(), different API

Not restored:

  • _PyDict_ContainsId()
  • _PyDict_DelItemId()
  • _PyDict_GetItemIdWithError()
  • _PyDict_SetItemId()
  • _PyEval_GetBuiltinId()
  • _PyLong_NumBits()
  • _PyObject_CallMethodIdNoArgs()
  • _PyObject_CallMethodIdObjArgs()
  • _PyObject_CallMethodIdOneArg()
  • _PyObject_LookupSpecialId()
  • _PyObject_SetAttrId()
  • _PyObject_VectorcallMethodId()
  • _PyTime_AsSecondsDouble()
  • _PyTime_FromTimeval()
  • _PyTime_GetSystemClock()
  • _PyTime_t
  • _PyType_LookupId()
  • _PyUnicode_EqualToASCIIId()

Pending PR:

Removed:

  • _PyErr_WriteUnraisable()

Not restored, deprecated:

  • 2to3 module removal
  • <ctype.h>
  • <unistd.h>
  • Logger.warn()
  • PyCFunction_Call()
  • PyEval_AcquireLock()
  • PyEval_CallObject()
  • PyEval_InitThreads()
  • PyEval_ReleaseLock()
  • PyObject_AsCharBuffer()
  • PyObject_AsReadBuffer()
  • PyObject_AsWriteBuffer()
  • PySys_SetArgv()
  • PySys_SetArgvEx()
  • PySys_SetPath()
  • PyUnicode_AS_DATA
  • PyUnicode_AS_UNICODE()
  • PyUnicode_GetSize()
  • Py_SetProgramName()
  • Py_TRASHCAN_SAFE_BEGIN and Py_TRASHCAN_SAFE_END
  • importlib.resources removed functions
  • locale.resetlocale()
  • typing.re
  • unittest-related removals

@vstinner
Copy link
Member Author

With this change, I can successfully install cffi 1.16.0 and numpy 1.26.2.

@vstinner
Copy link
Member Author

vstinner commented Nov 15, 2023

With this change, I can successfully install cffi 1.16.0 and numpy 1.26.2.

Oh, on Fedora 39, GCC only emits a warning when using an undefined function, and so the build was successful, but numpy calls a function which doesn't exist anymore! My script to test numpy:

set -e -x
wget https://files.pythonhosted.org/packages/dd/2b/205ddff2314d4eea852e31d53b8e55eb3f32b292efc3dd86bd827ab9019d/numpy-1.26.2.tar.gz
rm -rf numpy-1.26.2
tar -xf numpy-1.26.2.tar.gz
cd numpy-1.26.2/
/opt/py313/bin/python3.13 -m venv env
export CFLAGS='-Werror=implicit-function-declaration'
export LANG=
env/bin/python -m pip install . -v

In fact, 3 other changes are needed by numpy (UPDATE: done):

With these additional changes, I can successfully build numpy with -Werror=implicit-function-declaration compiler flag.

Restore removed private C API functions, macros and structures which
have no simple replacement for now:

* _PyDict_GetItem_KnownHash()
* _PyDict_NewPresized()
* _PyHASH_BITS
* _PyHASH_IMAG
* _PyHASH_INF
* _PyHASH_MODULUS
* _PyHASH_MULTIPLIER
* _PyLong_Copy()
* _PyLong_FromDigits()
* _PyLong_New()
* _PyLong_Sign()
* _PyObject_CallMethodId()
* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_EXTRA_INIT
* _PyObject_FastCallDict()
* _PyObject_GetAttrId()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyStack_AsDict()
* _PyThread_CurrentFrames()
* _PyUnicodeWriter structure
* _PyUnicodeWriter_Dealloc()
* _PyUnicodeWriter_Finish()
* _PyUnicodeWriter_Init()
* _PyUnicodeWriter_Prepare()
* _PyUnicodeWriter_PrepareKind()
* _PyUnicodeWriter_WriteASCIIString()
* _PyUnicodeWriter_WriteChar()
* _PyUnicodeWriter_WriteLatin1String()
* _PyUnicodeWriter_WriteStr()
* _PyUnicodeWriter_WriteSubstring()
* _PyUnicode_AsString()
* _PyUnicode_FromId()
* _PyVectorcall_Function()
* _Py_HashDouble()
* _Py_HashPointer()
* _Py_IDENTIFIER()
* _Py_c_abs()
* _Py_c_diff()
* _Py_c_neg()
* _Py_c_pow()
* _Py_c_prod()
* _Py_c_quot()
* _Py_c_sum()
* _Py_static_string()
* _Py_static_string_init()
@vstinner
Copy link
Member Author

Restore _Py_HashDouble() function.

I updated the PR to restore _Py_HashDouble() and _Py_HashPointer() functions.

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

1 participant