STINNER Victor <vstin...@python.org> added the comment:
Oh, I forgot about this issue. Let me rebuild the context. Copy of the What's New in Python 3.10 entry: "Removed the unicodedata.ucnhash_CAPI attribute which was an internal PyCapsule object. The related private _PyUnicode_Name_CAPI structure was moved to the internal C API. (Contributed by Victor Stinner in bpo-42157.)" The C API changes. Python <= 3.9: typedef struct { /* Size of this struct */ int size; /* Get name for a given character code. Returns non-zero if success, zero if not. Does not set Python exceptions. If self is NULL, data come from the default version of the database. If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */ int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen, int with_alias_and_seq); /* Get character code for a given name. Same error handling as for getname. */ int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code, int with_named_seq); } _PyUnicode_Name_CAPI; Python >= 3.10: typedef struct { /* Get name for a given character code. Returns non-zero if success, zero if not. Does not set Python exceptions. */ int (*getname)(Py_UCS4 code, char* buffer, int buflen, int with_alias_and_seq); /* Get character code for a given name. Same error handling as for getname(). */ int (*getcode)(const char* name, int namelen, Py_UCS4* code, int with_named_seq); } _PyUnicode_Name_CAPI; Changes: * _PyUnicode_Name_CAPI.size was removed * getname and getcode functions have no more "self" argument There was also a "void *state" parameter in commit https://github.com/python/cpython/commit/47e1afd2a1793b5818a16c41307a4ce976331649 but it was removed later. In Python, it's used in two places: * unicodeobject.c: "\N{...}" format to get a code point by its name * codecs.c: PyCodec_NameReplaceErrors(), "namereplace" error handler Both used self=NULL in Python 3.9. It was simpler to remove the C API rather than trying to keep backward compatibility. The problem was to support the "self" parameter. See the comment: --- // Check if self is an unicodedata.UCD instance. // If self is NULL (when the PyCapsule C API is used), return 0. // PyModule_Check() is used to avoid having to retrieve the ucd_type. // See unicodedata_functions comment to the rationale of this macro. #define UCD_Check(self) (self != NULL && !PyModule_Check(self)) --- In my PR, I wrote: "I prefer to merge this early in the 3.10 dev cycle, to increase chances of getting early user feedback if this change breaks 3rd party applications. Thanks for the review @methane. Usually, features require 2 Python release to be removed, with a deprecation first. But this specific case is really weird. I chose to remove it immediately. IMO it was exposed in public "by mistake", whereas a private attribute would be enough for internal usage." https://github.com/python/cpython/pull/22994#issuecomment-716958371 ---------- nosy: +koubaa, methane _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44418> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com