Skip to content

Commit bb2b9ba

Browse files
gh-143897: Remove the isxidstart() and isxidcontinue() methods of unicodedata.ucd_3_2_0 (GH-143898)
They are now only exposed as the unicodedata function.
1 parent 7dca4e3 commit bb2b9ba

File tree

4 files changed

+39
-57
lines changed

4 files changed

+39
-57
lines changed

Lib/test/test_unicodedata.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,7 @@ def test_method_checksum(self):
8383
self.assertEqual(result, self.expectedchecksum)
8484

8585

86-
class UnicodeFunctionsTest(unittest.TestCase):
87-
db = unicodedata
88-
old = False
89-
90-
# Update this if the database changes. Make sure to do a full rebuild
91-
# (e.g. 'make distclean && make') to get the correct checksum.
92-
expectedchecksum = ('83cc43a2fbb779185832b4c049217d80b05bf349'
93-
if quicktest else
94-
'65670ae03a324c5f9e826a4de3e25bae4d73c9b7')
86+
class BaseUnicodeFunctionsTest:
9587

9688
def test_function_checksum(self):
9789
db = self.db
@@ -589,6 +581,16 @@ def test_east_asian_width_unassigned(self):
589581
self.assertEqual(eaw(char), 'A')
590582
self.assertIs(self.db.name(char, None), None)
591583

584+
class UnicodeFunctionsTest(unittest.TestCase, BaseUnicodeFunctionsTest):
585+
db = unicodedata
586+
old = False
587+
588+
# Update this if the database changes. Make sure to do a full rebuild
589+
# (e.g. 'make distclean && make') to get the correct checksum.
590+
expectedchecksum = ('83cc43a2fbb779185832b4c049217d80b05bf349'
591+
if quicktest else
592+
'65670ae03a324c5f9e826a4de3e25bae4d73c9b7')
593+
592594
def test_isxidstart(self):
593595
self.assertTrue(self.db.isxidstart('S'))
594596
self.assertTrue(self.db.isxidstart('\u0AD0')) # GUJARATI OM
@@ -832,18 +834,13 @@ def graphemes(*args):
832834
['a', '\U0001F1FA\U0001F1E6', '\U0001F1FA\U0001F1F3'])
833835

834836

835-
class Unicode_3_2_0_FunctionsTest(UnicodeFunctionsTest):
837+
class Unicode_3_2_0_FunctionsTest(unittest.TestCase, BaseUnicodeFunctionsTest):
836838
db = unicodedata.ucd_3_2_0
837839
old = True
838840
expectedchecksum = ('f4526159891a4b766dd48045646547178737ba09'
839841
if quicktest else
840842
'f217b8688d7bdff31db4207e078a96702f091597')
841843

842-
test_grapheme_cluster_break = None
843-
test_indic_conjunct_break = None
844-
test_extended_pictographic = None
845-
test_grapheme_break = None
846-
847844

848845
class UnicodeMiscTest(unittest.TestCase):
849846
db = unicodedata
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove the :meth:`!isxidstart` and :meth:`!isxidcontinue` methods of
2+
:data:`unicodedata.ucd_3_2_0`. They are now only exposed as
3+
:func:`unicodedata.isxidstart` and :func:`unicodedata.isxidcontinue`.

Modules/clinic/unicodedata.c.h

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/unicodedata.c

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,8 @@ unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value)
15651565
}
15661566

15671567
/*[clinic input]
1568-
unicodedata.UCD.isxidstart
1568+
unicodedata.isxidstart
15691569
1570-
self: self
15711570
chr: int(accept={str})
15721571
/
15731572
@@ -1576,24 +1575,15 @@ Return True if the character has the XID_Start property, else False.
15761575
[clinic start generated code]*/
15771576

15781577
static PyObject *
1579-
unicodedata_UCD_isxidstart_impl(PyObject *self, int chr)
1580-
/*[clinic end generated code: output=944005823c72c3ef input=9353f88d709c21fb]*/
1578+
unicodedata_isxidstart_impl(PyObject *module, int chr)
1579+
/*[clinic end generated code: output=7ae0e1a3915aa031 input=3812717f3a6bfc56]*/
15811580
{
1582-
if (UCD_Check(self)) {
1583-
const change_record *old = get_old_record(self, chr);
1584-
if (old->category_changed == 0) {
1585-
/* unassigned */
1586-
Py_RETURN_FALSE;
1587-
}
1588-
}
1589-
15901581
return PyBool_FromLong(_PyUnicode_IsXidStart(chr));
15911582
}
15921583

15931584
/*[clinic input]
1594-
unicodedata.UCD.isxidcontinue
1585+
unicodedata.isxidcontinue
15951586
1596-
self: self
15971587
chr: int(accept={str})
15981588
/
15991589
@@ -1602,17 +1592,9 @@ Return True if the character has the XID_Continue property, else False.
16021592
[clinic start generated code]*/
16031593

16041594
static PyObject *
1605-
unicodedata_UCD_isxidcontinue_impl(PyObject *self, int chr)
1606-
/*[clinic end generated code: output=9438dcbff5ca3e41 input=bbb8dd3ac0d2d709]*/
1595+
unicodedata_isxidcontinue_impl(PyObject *module, int chr)
1596+
/*[clinic end generated code: output=517caa8b38c73aed input=a971ed6e57cac374]*/
16071597
{
1608-
if (UCD_Check(self)) {
1609-
const change_record *old = get_old_record(self, chr);
1610-
if (old->category_changed == 0) {
1611-
/* unassigned */
1612-
Py_RETURN_FALSE;
1613-
}
1614-
}
1615-
16161598
return PyBool_FromLong(_PyUnicode_IsXidContinue(chr));
16171599
}
16181600

@@ -2128,10 +2110,12 @@ static PyMethodDef unicodedata_functions[] = {
21282110
UNICODEDATA_INDIC_CONJUNCT_BREAK_METHODDEF
21292111
UNICODEDATA_EXTENDED_PICTOGRAPHIC_METHODDEF
21302112
UNICODEDATA_ITER_GRAPHEMES_METHODDEF
2113+
UNICODEDATA_ISXIDSTART_METHODDEF
2114+
UNICODEDATA_ISXIDCONTINUE_METHODDEF
21312115

21322116
// The following definitions are shared between the module
21332117
// and the UCD class.
2134-
#define DB_methods (unicodedata_functions + 4)
2118+
#define DB_methods (unicodedata_functions + 6)
21352119

21362120
UNICODEDATA_UCD_DECIMAL_METHODDEF
21372121
UNICODEDATA_UCD_DIGIT_METHODDEF
@@ -2143,8 +2127,6 @@ static PyMethodDef unicodedata_functions[] = {
21432127
UNICODEDATA_UCD_EAST_ASIAN_WIDTH_METHODDEF
21442128
UNICODEDATA_UCD_DECOMPOSITION_METHODDEF
21452129
UNICODEDATA_UCD_NAME_METHODDEF
2146-
UNICODEDATA_UCD_ISXIDSTART_METHODDEF
2147-
UNICODEDATA_UCD_ISXIDCONTINUE_METHODDEF
21482130
UNICODEDATA_UCD_LOOKUP_METHODDEF
21492131
UNICODEDATA_UCD_IS_NORMALIZED_METHODDEF
21502132
UNICODEDATA_UCD_NORMALIZE_METHODDEF

0 commit comments

Comments
 (0)