Skip to content

Commit 920cb64

Browse files
authored
bpo-42157: unicodedata avoids references to UCD_Type (GH-22990)
* UCD_Check() uses PyModule_Check() * Simplify the internal _PyUnicode_Name_CAPI structure: * Remove size and state members * Remove state and self parameters of getcode() and getname() functions * Remove global_module_state
1 parent 8374d2e commit 920cb64

File tree

7 files changed

+126
-136
lines changed

7 files changed

+126
-136
lines changed

Doc/whatsnew/3.10.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,8 @@ Porting to Python 3.10
408408
(Contributed by Inada Naoki in :issue:`36346`.)
409409

410410
* The private ``_PyUnicode_Name_CAPI`` structure of the PyCapsule API
411-
``unicodedata.ucnhash_CAPI`` moves to the internal C API. Moreover,
412-
the structure gets a new ``state`` member which must be passed to the
413-
``getcode()`` and ``getname()`` functions.
414-
(Contributed by Victor Stinner in :issue:`1635741`.)
411+
``unicodedata.ucnhash_CAPI`` moves to the internal C API.
412+
(Contributed by Victor Stinner in :issue:`42157`.)
415413

416414
Deprecated
417415
----------

Include/internal/pycore_ucnhash.h

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,15 @@ extern "C" {
1515

1616
typedef struct {
1717

18-
/* Size of this struct */
19-
int size;
20-
21-
// state which must be passed as the first parameter to getname()
22-
// and getcode()
23-
void *state;
24-
25-
/* Get name for a given character code. Returns non-zero if
26-
success, zero if not. Does not set Python exceptions.
27-
If self is NULL, data come from the default version of the database.
28-
If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */
29-
int (*getname)(void *state, PyObject *self, Py_UCS4 code,
30-
char* buffer, int buflen,
18+
/* Get name for a given character code.
19+
Returns non-zero if success, zero if not.
20+
Does not set Python exceptions. */
21+
int (*getname)(Py_UCS4 code, char* buffer, int buflen,
3122
int with_alias_and_seq);
3223

33-
/* Get character code for a given name. Same error handling
34-
as for getname. */
35-
int (*getcode)(void *state, PyObject *self,
36-
const char* name, int namelen, Py_UCS4* code,
24+
/* Get character code for a given name.
25+
Same error handling as for getname(). */
26+
int (*getcode)(const char* name, int namelen, Py_UCS4* code,
3727
int with_named_seq);
3828

3929
} _PyUnicode_Name_CAPI;

Misc/NEWS.d/next/C API/2020-10-16-10-47-17.bpo-1635741.e3BcPM.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The private ``_PyUnicode_Name_CAPI`` structure of the PyCapsule API
2+
``unicodedata.ucnhash_CAPI`` moves to the internal C API.
3+
Patch by Victor Stinner.

0 commit comments

Comments
 (0)