Skip to content

Commit c9848e2

Browse files
committed
rename break_graphemes to iter_graphemes
1 parent b103be7 commit c9848e2

File tree

2 files changed

+21
-40
lines changed

2 files changed

+21
-40
lines changed

Modules/clinic/unicodedata.c.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,32 +407,32 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
407407
return return_value;
408408
}
409409

410-
PyDoc_STRVAR(unicodedata_UCD_break_graphemes__doc__,
411-
"break_graphemes($self, unistr, /)\n"
410+
PyDoc_STRVAR(unicodedata_UCD_iter_graphemes__doc__,
411+
"iter_graphemes($self, unistr, /)\n"
412412
"--\n"
413413
"\n"
414414
"Returns an iterator to iterate over grapheme clusters in unistr.\n"
415415
"\n"
416416
"It uses extended grapheme cluster rules from TR29.");
417417

418-
#define UNICODEDATA_UCD_BREAK_GRAPHEMES_METHODDEF \
419-
{"break_graphemes", (PyCFunction)unicodedata_UCD_break_graphemes, METH_O, unicodedata_UCD_break_graphemes__doc__},
418+
#define UNICODEDATA_UCD_ITER_GRAPHEMES_METHODDEF \
419+
{"iter_graphemes", (PyCFunction)unicodedata_UCD_iter_graphemes, METH_O, unicodedata_UCD_iter_graphemes__doc__},
420420

421421
static PyObject *
422-
unicodedata_UCD_break_graphemes_impl(PyObject *self, PyObject *unistr);
422+
unicodedata_UCD_iter_graphemes_impl(PyObject *self, PyObject *unistr);
423423

424424
static PyObject *
425-
unicodedata_UCD_break_graphemes(PyObject *self, PyObject *arg)
425+
unicodedata_UCD_iter_graphemes(PyObject *self, PyObject *arg)
426426
{
427427
PyObject *return_value = NULL;
428428
PyObject *unistr;
429429

430-
if (!PyArg_Parse(arg, "U:break_graphemes", &unistr)) {
430+
if (!PyArg_Parse(arg, "U:iter_graphemes", &unistr)) {
431431
goto exit;
432432
}
433-
return_value = unicodedata_UCD_break_graphemes_impl(self, unistr);
433+
return_value = unicodedata_UCD_iter_graphemes_impl(self, unistr);
434434

435435
exit:
436436
return return_value;
437437
}
438-
/*[clinic end generated code: output=e7aa6367f1c3caf3 input=a9049054013a1b77]*/
438+
/*[clinic end generated code: output=88c185f6e080eec9 input=a9049054013a1b77]*/

Modules/unicodedata.c

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ unicodedata_UCD_lookup_impl(PyObject *self, const char *name,
12771277
typedef struct {
12781278
PyObject_HEAD
12791279
PyObject* str;
1280-
int pos;
1280+
Py_ssize_t pos;
12811281
} GraphemeClusterIterator;
12821282

12831283
void GCI_Del(PyObject* x)
@@ -1322,36 +1322,17 @@ PyObject* GCI_iternext(PyObject *self)
13221322

13231323
static PyTypeObject GraphemeClusterIteratorType = {
13241324
PyVarObject_HEAD_INIT(NULL, 0)
1325-
"unicodedata.GraphemeClusterIterator", /*tp_name*/
1326-
sizeof(GraphemeClusterIterator), /*tp_basicsize*/
1327-
0, /*tp_itemsize*/
1328-
(destructor)GCI_Del, /*tp_dealloc*/
1329-
0, /*tp_print*/
1330-
0, /*tp_getattr*/
1331-
0, /*tp_setattr*/
1332-
0, /*tp_compare*/
1333-
0, /*tp_repr*/
1334-
0, /*tp_as_number*/
1335-
0, /*tp_as_sequence*/
1336-
0, /*tp_as_mapping*/
1337-
0, /*tp_hash */
1338-
0, /*tp_call*/
1339-
0, /*tp_str*/
1340-
0, /*tp_getattro*/
1341-
0, /*tp_setattro*/
1342-
0, /*tp_as_buffer*/
1343-
Py_TPFLAGS_DEFAULT,
1344-
"Internal grapheme cluster iterator object.", /* tp_doc */
1345-
0, /* tp_traverse */
1346-
0, /* tp_clear */
1347-
0, /* tp_richcompare */
1348-
0, /* tp_weaklistoffset */
1349-
GCI_iter, /* tp_iter: __iter__() method */
1350-
GCI_iternext /* tp_iternext: next() method */
1325+
.tp_name = "unicodedata.GraphemeClusterIterator",
1326+
.tp_basicsize = sizeof(GraphemeClusterIterator),
1327+
.tp_dealloc = (destructor)GCI_Del,
1328+
.tp_flags = Py_TPFLAGS_DEFAULT,
1329+
.tp_doc = "Internal grapheme cluster iterator object.",
1330+
.tp_iter = GCI_iter,
1331+
.tp_iternext = GCI_iternext
13511332
};
13521333

13531334
/*[clinic input]
1354-
unicodedata.UCD.break_graphemes
1335+
unicodedata.UCD.iter_graphemes
13551336
13561337
self: self
13571338
unistr: unicode
@@ -1363,8 +1344,8 @@ It uses extended grapheme cluster rules from TR29.
13631344
[clinic start generated code]*/
13641345

13651346
static PyObject *
1366-
unicodedata_UCD_break_graphemes_impl(PyObject *self, PyObject *unistr)
1367-
/*[clinic end generated code: output=3da536db1b0e5b12 input=d054bb6f190f6dc8]*/
1347+
unicodedata_UCD_iter_graphemes_impl(PyObject *self, PyObject *unistr)
1348+
/*[clinic end generated code: output=92374c1d94db4165 input=59c4794a7f2e6742]*/
13681349
{
13691350
GraphemeClusterIterator *gci = PyObject_New(GraphemeClusterIterator,
13701351
&GraphemeClusterIteratorType);
@@ -1394,7 +1375,7 @@ static PyMethodDef unicodedata_functions[] = {
13941375
UNICODEDATA_UCD_NAME_METHODDEF
13951376
UNICODEDATA_UCD_LOOKUP_METHODDEF
13961377
UNICODEDATA_UCD_NORMALIZE_METHODDEF
1397-
UNICODEDATA_UCD_BREAK_GRAPHEMES_METHODDEF
1378+
UNICODEDATA_UCD_ITER_GRAPHEMES_METHODDEF
13981379
{NULL, NULL} /* sentinel */
13991380
};
14001381

0 commit comments

Comments
 (0)