mirror of
https://github.com/python/cpython.git
synced 2024-11-23 01:45:25 +08:00
8a8e9204d1
Revert "gh-115398: Increment PyExpat_CAPI_MAGIC for SetReparseDeferralEnabled addition (GH-116301)" This reverts part of commiteda2963378
. Why? this comment buried in an earlier code review explains: I checked again how that value is used in practice, it's here:0c80da4c14/Modules/_elementtree.c (L4363-L4372)
Based on that code my understanding is that loading bigger structs from the future is considered okay unless `PyExpat_CAPI_MAGIC` differs, which implies that (1) magic needs to stay the same to support loading the future from the past and (2) that `PyExpat_CAPI_MAGIC` should only ever change for changes that do not increase size (but keep it constant). To summarize, that supports your argument. I checked branches 3.8, 3.9, 3.10, 3.11, 3.12 now and they all have the same comparison code there so reverting that magic string bump will support seamless backporting.
58 lines
2.5 KiB
C
58 lines
2.5 KiB
C
/* Stuff to export relevant 'expat' entry points from pyexpat to other
|
|
* parser modules, such as cElementTree. */
|
|
|
|
/* note: you must import expat.h before importing this module! */
|
|
|
|
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1"
|
|
#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
|
|
|
|
struct PyExpat_CAPI
|
|
{
|
|
char* magic; /* set to PyExpat_CAPI_MAGIC */
|
|
int size; /* set to sizeof(struct PyExpat_CAPI) */
|
|
int MAJOR_VERSION;
|
|
int MINOR_VERSION;
|
|
int MICRO_VERSION;
|
|
/* pointers to selected expat functions. add new functions at
|
|
the end, if needed */
|
|
const XML_LChar * (*ErrorString)(enum XML_Error code);
|
|
enum XML_Error (*GetErrorCode)(XML_Parser parser);
|
|
XML_Size (*GetErrorColumnNumber)(XML_Parser parser);
|
|
XML_Size (*GetErrorLineNumber)(XML_Parser parser);
|
|
enum XML_Status (*Parse)(
|
|
XML_Parser parser, const char *s, int len, int isFinal);
|
|
XML_Parser (*ParserCreate_MM)(
|
|
const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite,
|
|
const XML_Char *namespaceSeparator);
|
|
void (*ParserFree)(XML_Parser parser);
|
|
void (*SetCharacterDataHandler)(
|
|
XML_Parser parser, XML_CharacterDataHandler handler);
|
|
void (*SetCommentHandler)(
|
|
XML_Parser parser, XML_CommentHandler handler);
|
|
void (*SetDefaultHandlerExpand)(
|
|
XML_Parser parser, XML_DefaultHandler handler);
|
|
void (*SetElementHandler)(
|
|
XML_Parser parser, XML_StartElementHandler start,
|
|
XML_EndElementHandler end);
|
|
void (*SetNamespaceDeclHandler)(
|
|
XML_Parser parser, XML_StartNamespaceDeclHandler start,
|
|
XML_EndNamespaceDeclHandler end);
|
|
void (*SetProcessingInstructionHandler)(
|
|
XML_Parser parser, XML_ProcessingInstructionHandler handler);
|
|
void (*SetUnknownEncodingHandler)(
|
|
XML_Parser parser, XML_UnknownEncodingHandler handler,
|
|
void *encodingHandlerData);
|
|
void (*SetUserData)(XML_Parser parser, void *userData);
|
|
void (*SetStartDoctypeDeclHandler)(XML_Parser parser,
|
|
XML_StartDoctypeDeclHandler start);
|
|
enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding);
|
|
int (*DefaultUnknownEncodingHandler)(
|
|
void *encodingHandlerData, const XML_Char *name, XML_Encoding *info);
|
|
/* might be NULL for expat < 2.1.0 */
|
|
int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt);
|
|
/* might be NULL for expat < 2.6.0 */
|
|
XML_Bool (*SetReparseDeferralEnabled)(XML_Parser parser, XML_Bool enabled);
|
|
/* always add new stuff to the end! */
|
|
};
|
|
|