mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
add a replacement API for PyCObject, PyCapsule #5630
All stdlib modules with C-APIs now use this. Patch by Larry Hastings
This commit is contained in:
parent
c679fd8efc
commit
b173f7853e
37 changed files with 943 additions and 149 deletions
|
|
@ -1793,12 +1793,12 @@ __create_codec(PyObject *ignore, PyObject *arg)
|
|||
MultibyteCodecObject *self;
|
||||
MultibyteCodec *codec;
|
||||
|
||||
if (!PyCObject_Check(arg)) {
|
||||
if (!PyCapsule_IsValid(arg, PyMultibyteCodec_CAPSULE_NAME)) {
|
||||
PyErr_SetString(PyExc_ValueError, "argument type invalid");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
codec = PyCObject_AsVoidPtr(arg);
|
||||
codec = PyCapsule_GetPointer(arg, PyMultibyteCodec_CAPSULE_NAME);
|
||||
if (codec->codecinit != NULL && codec->codecinit(codec->config) != 0)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue