Skip to content

Commit 209f300

Browse files
committed
update capsule API
1 parent 9d538e4 commit 209f300

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Include/pyexpat.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ struct PyExpat_CAPI
5252
int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt);
5353
/* might be NULL for expat < 2.6.0 */
5454
XML_Bool (*SetReparseDeferralEnabled)(XML_Parser parser, XML_Bool enabled);
55+
/* might be NULL for expat < 2.7.2 */
56+
XML_Bool (*SetAllocTrackerActivationThreshold)(
57+
XML_Parser parser, unsigned long long activationThresholdBytes);
58+
XML_Bool (*SetAllocTrackerMaximumAmplification)(
59+
XML_Parser parser, float maxAmplificationFactor);
5560
/* always add new stuff to the end! */
5661
};
5762

Modules/pyexpat.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,13 @@ pyexpat_exec(PyObject *mod)
22852285
#else
22862286
capi->SetReparseDeferralEnabled = NULL;
22872287
#endif
2288+
#if XML_COMBINED_VERSION >= 20702
2289+
capi->SetAllocTrackerActivationThreshold = XML_SetAllocTrackerActivationThreshold;
2290+
capi->SetAllocTrackerMaximumAmplification = XML_SetAllocTrackerMaximumAmplification;
2291+
#else
2292+
capi->SetAllocTrackerActivationThreshold = NULL;
2293+
capi->SetAllocTrackerMaximumAmplification = NULL;
2294+
#endif
22882295

22892296
/* export using capsule */
22902297
PyObject *capi_object = PyCapsule_New(capi, PyExpat_CAPSULE_NAME,

0 commit comments

Comments
 (0)