Skip to content

Commit 0376e29

Browse files
serhiy-storchakamiss-islington
authored andcommitted
gh-150285: Fix too long docstrings in the pyexpat module (GH-150294)
(cherry picked from commit 9da7923) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent c3d21e5 commit 0376e29

2 files changed

Lines changed: 90 additions & 76 deletions

File tree

Modules/clinic/pyexpat.c.h

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

Modules/pyexpat.c

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ get_parse_result(pyexpat_state *state, xmlparseobject *self, int rv)
830830
#define MAX_CHUNK_SIZE (1 << 20)
831831

832832
/*[clinic input]
833+
@permit_long_summary
833834
pyexpat.xmlparser.SetReparseDeferralEnabled
834835
835836
enabled: bool
@@ -841,7 +842,7 @@ Enable/Disable reparse deferral; enabled by default with Expat >=2.6.0.
841842
static PyObject *
842843
pyexpat_xmlparser_SetReparseDeferralEnabled_impl(xmlparseobject *self,
843844
int enabled)
844-
/*[clinic end generated code: output=5ec539e3b63c8c49 input=021eb9e0bafc32c5]*/
845+
/*[clinic end generated code: output=5ec539e3b63c8c49 input=6d3743500dcee799]*/
845846
{
846847
#if XML_COMBINED_VERSION >= 20600
847848
XML_SetReparseDeferralEnabled(self->itself, enabled ? XML_TRUE : XML_FALSE);
@@ -1053,18 +1054,19 @@ pyexpat_xmlparser_GetBase_impl(xmlparseobject *self)
10531054
}
10541055

10551056
/*[clinic input]
1056-
@permit_long_docstring_body
1057+
@permit_long_summary
10571058
pyexpat.xmlparser.GetInputContext
10581059
10591060
Return the untranslated text of the input that caused the current event.
10601061
1061-
If the event was generated by a large amount of text (such as a start tag
1062-
for an element with many attributes), not all of the text may be available.
1062+
If the event was generated by a large amount of text (such as
1063+
a start tag for an element with many attributes), not all of the
1064+
text may be available.
10631065
[clinic start generated code]*/
10641066

10651067
static PyObject *
10661068
pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self)
1067-
/*[clinic end generated code: output=a88026d683fc22cc input=925cea010fdfa682]*/
1069+
/*[clinic end generated code: output=a88026d683fc22cc input=a672f48f09bb73d2]*/
10681070
{
10691071
if (self->in_callback) {
10701072
int offset, size;
@@ -1191,7 +1193,6 @@ pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag)
11911193
#if XML_COMBINED_VERSION >= 19505
11921194
/*[clinic input]
11931195
@permit_long_summary
1194-
@permit_long_docstring_body
11951196
pyexpat.xmlparser.UseForeignDTD
11961197
11971198
cls: defining_class
@@ -1200,15 +1201,16 @@ pyexpat.xmlparser.UseForeignDTD
12001201
12011202
Allows the application to provide an artificial external subset if one is not specified as part of the document instance.
12021203
1203-
This readily allows the use of a 'default' document type controlled by the
1204-
application, while still getting the advantage of providing document type
1205-
information to the parser. 'flag' defaults to True if not provided.
1204+
This readily allows the use of a 'default' document type controlled
1205+
by the application, while still getting the advantage of providing
1206+
document type information to the parser. 'flag' defaults to True if
1207+
not provided.
12061208
[clinic start generated code]*/
12071209

12081210
static PyObject *
12091211
pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, PyTypeObject *cls,
12101212
int flag)
1211-
/*[clinic end generated code: output=d7d98252bd25a20f input=c2264845d8c0029c]*/
1213+
/*[clinic end generated code: output=d7d98252bd25a20f input=2920baa5bf24714d]*/
12121214
{
12131215
pyexpat_state *state = PyType_GetModuleState(cls);
12141216
enum XML_Error rc;
@@ -1268,7 +1270,6 @@ set_maximum_amplification(xmlparseobject *self,
12681270
#if XML_COMBINED_VERSION >= 20400
12691271
/*[clinic input]
12701272
@permit_long_summary
1271-
@permit_long_docstring_body
12721273
pyexpat.xmlparser.SetBillionLaughsAttackProtectionActivationThreshold
12731274
12741275
cls: defining_class
@@ -1277,21 +1278,22 @@ pyexpat.xmlparser.SetBillionLaughsAttackProtectionActivationThreshold
12771278
12781279
Sets the number of output bytes needed to activate protection against billion laughs attacks.
12791280
1280-
The number of output bytes includes amplification from entity expansion
1281-
and reading DTD files.
1281+
The number of output bytes includes amplification from entity
1282+
expansion and reading DTD files.
12821283
1283-
Parser objects usually have a protection activation threshold of 8 MiB,
1284-
but the actual default value depends on the underlying Expat library.
1284+
Parser objects usually have a protection activation threshold of
1285+
8 MiB, but the actual default value depends on the underlying Expat
1286+
library.
12851287
1286-
Activation thresholds below 4 MiB are known to break support for DITA 1.3
1287-
payload and are hence not recommended.
1288+
Activation thresholds below 4 MiB are known to break support for
1289+
DITA 1.3 payload and are hence not recommended.
12881290
[clinic start generated code]*/
12891291

12901292
static PyObject *
12911293
pyexpat_xmlparser_SetBillionLaughsAttackProtectionActivationThreshold_impl(xmlparseobject *self,
12921294
PyTypeObject *cls,
12931295
unsigned long long threshold)
1294-
/*[clinic end generated code: output=0c082342f1c78114 input=fa2f91f26b62a42a]*/
1296+
/*[clinic end generated code: output=0c082342f1c78114 input=8d84b0e3a873cdba]*/
12951297
{
12961298
return set_activation_threshold(
12971299
self, cls, threshold,
@@ -1303,7 +1305,6 @@ pyexpat_xmlparser_SetBillionLaughsAttackProtectionActivationThreshold_impl(xmlpa
13031305
#if XML_COMBINED_VERSION >= 20400
13041306
/*[clinic input]
13051307
@permit_long_summary
1306-
@permit_long_docstring_body
13071308
pyexpat.xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification
13081309
13091310
cls: defining_class
@@ -1312,25 +1313,28 @@ pyexpat.xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification
13121313
13131314
Sets the maximum tolerated amplification factor for protection against billion laughs attacks.
13141315
1315-
The amplification factor is calculated as "(direct + indirect) / direct"
1316-
while parsing, where "direct" is the number of bytes read from the primary
1317-
document in parsing and "indirect" is the number of bytes added by expanding
1318-
entities and reading external DTD files, combined.
1316+
The amplification factor is calculated as "(direct + indirect) /
1317+
direct" while parsing, where "direct" is the number of bytes read
1318+
from the primary document in parsing and "indirect" is the number of
1319+
bytes added by expanding entities and reading external DTD files,
1320+
combined.
13191321
1320-
The 'max_factor' value must be a non-NaN floating point value greater than
1321-
or equal to 1.0. Amplification factors greater than 30,000 can be observed
1322-
in the middle of parsing even with benign files in practice. In particular,
1323-
the activation threshold should be carefully chosen to avoid false positives.
1322+
The 'max_factor' value must be a non-NaN floating point value
1323+
greater than or equal to 1.0. Amplification factors greater than
1324+
30,000 can be observed in the middle of parsing even with benign
1325+
files in practice. In particular, the activation threshold should
1326+
be carefully chosen to avoid false positives.
13241327
13251328
Parser objects usually have a maximum amplification factor of 100,
1326-
but the actual default value depends on the underlying Expat library.
1329+
but the actual default value depends on the underlying Expat
1330+
library.
13271331
[clinic start generated code]*/
13281332

13291333
static PyObject *
13301334
pyexpat_xmlparser_SetBillionLaughsAttackProtectionMaximumAmplification_impl(xmlparseobject *self,
13311335
PyTypeObject *cls,
13321336
float max_factor)
1333-
/*[clinic end generated code: output=c590439eadf463fa input=cc1e97c1fd2bd950]*/
1337+
/*[clinic end generated code: output=c590439eadf463fa input=d0f11971c5b9e98b]*/
13341338
{
13351339
return set_maximum_amplification(
13361340
self, cls, max_factor,
@@ -1342,7 +1346,6 @@ pyexpat_xmlparser_SetBillionLaughsAttackProtectionMaximumAmplification_impl(xmlp
13421346
#if XML_COMBINED_VERSION >= 20702
13431347
/*[clinic input]
13441348
@permit_long_summary
1345-
@permit_long_docstring_body
13461349
pyexpat.xmlparser.SetAllocTrackerActivationThreshold
13471350
13481351
cls: defining_class
@@ -1351,15 +1354,16 @@ pyexpat.xmlparser.SetAllocTrackerActivationThreshold
13511354
13521355
Sets the number of allocated bytes of dynamic memory needed to activate protection against disproportionate use of RAM.
13531356
1354-
Parser objects usually have an allocation activation threshold of 64 MiB,
1355-
but the actual default value depends on the underlying Expat library.
1357+
Parser objects usually have an allocation activation threshold of
1358+
64 MiB, but the actual default value depends on the underlying Expat
1359+
library.
13561360
[clinic start generated code]*/
13571361

13581362
static PyObject *
13591363
pyexpat_xmlparser_SetAllocTrackerActivationThreshold_impl(xmlparseobject *self,
13601364
PyTypeObject *cls,
13611365
unsigned long long threshold)
1362-
/*[clinic end generated code: output=bed7e93207ba08c5 input=b7a7a3e3d054286a]*/
1366+
/*[clinic end generated code: output=bed7e93207ba08c5 input=4728360b545de87a]*/
13631367
{
13641368
return set_activation_threshold(
13651369
self, cls, threshold,
@@ -1371,7 +1375,6 @@ pyexpat_xmlparser_SetAllocTrackerActivationThreshold_impl(xmlparseobject *self,
13711375
#if XML_COMBINED_VERSION >= 20702
13721376
/*[clinic input]
13731377
@permit_long_summary
1374-
@permit_long_docstring_body
13751378
pyexpat.xmlparser.SetAllocTrackerMaximumAmplification
13761379
13771380
cls: defining_class
@@ -1380,25 +1383,27 @@ pyexpat.xmlparser.SetAllocTrackerMaximumAmplification
13801383
13811384
Sets the maximum amplification factor between direct input and bytes of dynamic memory allocated.
13821385
1383-
The amplification factor is calculated as "allocated / direct" while parsing,
1384-
where "direct" is the number of bytes read from the primary document in parsing
1385-
and "allocated" is the number of bytes of dynamic memory allocated in the parser
1386-
hierarchy.
1386+
The amplification factor is calculated as "allocated / direct" while
1387+
parsing, where "direct" is the number of bytes read from the primary
1388+
document in parsing and "allocated" is the number of bytes of
1389+
dynamic memory allocated in the parser hierarchy.
13871390
1388-
The 'max_factor' value must be a non-NaN floating point value greater than
1389-
or equal to 1.0. Amplification factors greater than 100.0 can be observed
1390-
near the start of parsing even with benign files in practice. In particular,
1391-
the activation threshold should be carefully chosen to avoid false positives.
1391+
The 'max_factor' value must be a non-NaN floating point value
1392+
greater than or equal to 1.0. Amplification factors greater than
1393+
100.0 can be observed near the start of parsing even with benign
1394+
files in practice. In particular, the activation threshold should
1395+
be carefully chosen to avoid false positives.
13921396
13931397
Parser objects usually have a maximum amplification factor of 100,
1394-
but the actual default value depends on the underlying Expat library.
1398+
but the actual default value depends on the underlying Expat
1399+
library.
13951400
[clinic start generated code]*/
13961401

13971402
static PyObject *
13981403
pyexpat_xmlparser_SetAllocTrackerMaximumAmplification_impl(xmlparseobject *self,
13991404
PyTypeObject *cls,
14001405
float max_factor)
1401-
/*[clinic end generated code: output=6e44bd48c9b112a0 input=c6af7ccb76ae5c6b]*/
1406+
/*[clinic end generated code: output=6e44bd48c9b112a0 input=dd23ea3ef2069b69]*/
14021407
{
14031408
return set_maximum_amplification(
14041409
self, cls, max_factor,

0 commit comments

Comments
 (0)