summaryrefslogtreecommitdiff
path: root/Modules/_elementtree.c
AgeCommit message (Collapse)AuthorLines
2024-03-07[3.8] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) ↵Sebastian Pipping-0/+33
(GH-115623) (GH-116275) Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods: - `xml.etree.ElementTree.XMLParser.flush` - `xml.etree.ElementTree.XMLPullParser.flush` - `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled` - `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled` - `xml.sax.expatreader.ExpatParser.flush` Based on the "flush" idea from https://github.com/python/cpython/pull/115138#issuecomment-1932444270 . Includes code suggested-by: Snild Dolkow <snild@sony.com> and by core dev Serhiy Storchaka. Co-authored-by: Gregory P. Smith <greg@krypto.org>
2020-04-12bpo-31758: Prevent crashes when using an uninitialized ↵Miss Islington (bot)-0/+24
_elementtree.XMLParser object (GH-3997) (GH-19485) (cherry picked from commit 402e1cdb132f384e4dcde7a3d7ec7ea1fc7ab527)
2020-03-09bpo-39903: Fix double decref in _elementtree.Element.__getstate__ (GH-18850)Miss Islington (bot)-26/+17
(cherry picked from commit 88944a44aa84b0f3674939019b1befbc7a9dc874) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-09-14[3.8] bpo-37206: Unrepresentable default values no longer represented as ↵Serhiy Storchaka-9/+9
None. (GH-13933) (GH-16141) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all. (cherry picked from commit 279f44678c8b84a183f9eeb85e0b086228154497) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-07-24[3.8] bpo-37399: Correctly attach tail text to the last element/comment/pi ↵Stefan Behnel-24/+64
(GH-14856) (GH-14936) * bpo-37399: Correctly attach tail text to the last element/comment/pi, even when comments or pis are discarded. Also fixes the insertion of PIs when "insert_pis=True" is configured for a TreeBuilder.
2019-05-30bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer-8/+8
(GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
2019-05-17bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375)Zackery Spytz-2/+4
The final addition (cur += step) may overflow, so use size_t for "cur". "cur" is always positive (even for negative steps), so it is safe to use size_t here. Co-Authored-By: Martin Panter <vadmium+py@gmail.com>
2019-05-10bpo-35983: skip trashcan for subclasses (GH-11841)Jeroen Demeyer-2/+2
Add new trashcan macros to deal with a double deallocation that could occur when the `tp_dealloc` of a subclass calls the `tp_dealloc` of a base class and that base class uses the trashcan mechanism. Patch by Jeroen Demeyer.
2019-05-06bpo-36811: Fix a C compiler warning in _elementtree.c. (GH-13109)Stefan Behnel-1/+1
2019-05-03bpo-28238: Implement "{*}tag" and "{ns}*" wildcard tag selection support for ↵Stefan Behnel-1/+14
ElementPath, and extend the surrounding tests and docs. (GH-12997)
2019-05-01bpo-36676: Namespace prefix aware parsing support for the ET.XMLParser ↵Stefan Behnel-19/+121
target (GH-12885) * bpo-36676: Implement namespace prefix aware parsing support for the XMLParser target in ElementTree.
2019-05-01bpo-36673: Implement comment/PI parsing support for the TreeBuilder in ↵Stefan Behnel-29/+302
ElementTree. (#12883) * bpo-36673: Implement comment/PI parsing support for the TreeBuilder in ElementTree. * bpo-36673: Rewrite the comment/PI factory handling for the TreeBuilder in "_elementtree" to make it use the same factories as the ElementTree module, and to make it explicit when the comments/PIs are inserted into the tree and when they are not (which is the default).
2019-02-25bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)Serhiy Storchaka-7/+13
2018-12-18bpo-35502: Fix reference leaks in ElementTree.TreeBuilder. (GH-11170)Serhiy Storchaka-0/+5
2018-12-11bpo-35454: Fix miscellaneous minor issues in error handling. (#11077)Serhiy Storchaka-1/+4
* bpo-35454: Fix miscellaneous minor issues in error handling. * Fix a null pointer dereference.
2018-11-27bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka-1/+1
Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
2018-10-23Fix error handling bugs in _elementtree.c. (GH-10060)Zackery Spytz-11/+11
References could leak, NULL could be dereferenced, and the Expat parser could be double freed when some errors raised.
2018-10-19bpo-35013: Add more type checks for children of Element. (GH-9944)Serhiy Storchaka-25/+44
It is now guarantied that children of xml.etree.ElementTree.Element are Elements (at least in C implementation). Previously methods __setitem__(), __setstate__() and __deepcopy__() could be used for adding non-Element children.
2018-10-18bpo-35008: Fix possible leaks in Element.__setstate__(). (GH-9924)Serhiy Storchaka-31/+64
C implementation of xml.etree.ElementTree.Element.__setstate__() leaked references to children when called for already initialized element.
2018-10-14bpo-34941: Fix searching Element subclasses. (GH-9766)Serhiy Storchaka-12/+13
Methods find(), findtext() and findall() of xml.etree.ElementTree.Element were not able to find chldren which are instances of Element subclasses.
2018-10-04bpo-34739: Get rid of tp_getattro in xml.etree.ElementTree.XMLParser. (GH-9420)Serhiy Storchaka-23/+18
Use tp_members and tp_getset instead.
2018-09-18bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146)Christian Heimes-0/+5
The C accelerated _elementtree module now initializes hash randomization salt from _Py_HashSecret instead of libexpat's default CPRNG. Signed-off-by: Christian Heimes <christian@python.org> https://bugs.python.org/issue34623
2018-07-25bpo-34218: Fix a leak in _elementtree.c introduced in GH-6769. (GH-8460)Serhiy Storchaka-0/+1
2018-07-24bpo-29209: Remove old-deprecated features in ElementTree. (GH-6769)Serhiy Storchaka-72/+13
Also make getchildren() and getiterator() emitting a DeprecationWarning instead of PendingDeprecationWarning.
2017-12-15bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka-1/+1
arguments. (#4746)
2017-10-10bpo-31728: Prevent crashes in _elementtree due to unsafe cleanup of ↵Oren Milman-34/+28
Element.text and Element.tail (#3924)
2017-09-18bpo-31499, xml.etree: Fix xmlparser_gc_clear() crash (#3641)Victor Stinner-1/+5
* bpo-31499, xml.etree: Fix xmlparser_gc_clear() crash xml.etree: xmlparser_gc_clear() now sets self.parser to NULL to prevent a crash in xmlparser_dealloc() if xmlparser_gc_clear() was called previously by the garbage collector, because the parser was part of a reference cycle. Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
2017-09-14bpo-31455: Fix an assertion failure in ElementTree.XMLParser(). (#3545)scoder-2/+33
* Avoid calling "PyObject_GetAttrString()" (and potentially executing user code) with a live exception set. * Ignore only AttributeError on attribute lookups in ElementTree.XMLParser() and propagate all other exceptions.
2017-09-12bpo-31428: Prevent raising a SystemError in case the memo arg of ↵Oren Milman-4/+5
ElementTree.Element.__deepcopy__() isn't a dictionary. (#3512)
2017-08-24bpo-31095: fix potential crash during GC (GH-2974)INADA Naoki-1/+3
2017-07-10bpo-30892: Fix _elementtree module initialization (#2647)Victor Stinner-0/+5
Handle getattr(copy, 'deepcopy') error in _elementtree module initialization.
2017-07-03bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)Serhiy Storchaka-1/+1
the bare METH_FASTCALL be used for functions with positional-only parameters.
2017-04-19bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096)Serhiy Storchaka-2/+2
raised an error. Replace them with using concrete types API that never fails if appropriate.
2017-04-08Expand the PySlice_GetIndicesEx macro. (#1023)Serhiy Storchaka-6/+6
2017-03-30bpo-29204: Emit warnings for already deprecated ElementTree features. (#773)Serhiy Storchaka-2/+37
Element.getiterator() and the html parameter of XMLParser() were deprecated only in the documentation (since Python 3.2 and 3.4 correspondintly). Now using them emits a deprecation warning. * Don’t need check_warnings any more.
2017-03-30bpo-27863: Fixed multiple crashes in ElementTree. (#765)Serhiy Storchaka-48/+52
2017-01-17Run Argument Clinic: METH_VARARGS=>METH_FASTCALLVictor Stinner-1/+1
Issue #29286. Run Argument Clinic to get the new faster METH_FASTCALL calling convention for functions using "boring" positional arguments. Manually fix _elementtree: _elementtree_XMLParser_doctype() must remain consistent with the clinic code.
2016-12-21Merge from 3.6.Serhiy Storchaka-0/+2
2016-12-21Merge from 3.5.Serhiy Storchaka-0/+2
2016-12-21Issue #28871: Fixed a crash when deallocate deep ElementTree.Serhiy Storchaka-0/+2
2016-12-16Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka-1/+1
dict.
2016-12-09Use PyObject_CallFunctionObjArgs()Victor Stinner-8/+14
Issue #28915: Replace PyObject_CallFunction() with PyObject_CallFunctionObjArgs() when the format string was only made of "O" formats, PyObject* arguments. PyObject_CallFunctionObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string.
2016-12-09Use _PyObject_CallMethodIdObjArgs() in _elementtreeVictor Stinner-9/+10
Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() when the format string was only made of "O" formats, PyObject* arguments. _PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string.
2016-12-05Issue #28858: Remove _PyObject_CallArg1() macroVictor Stinner-5/+6
Replace _PyObject_CallArg1(func, arg) with PyObject_CallFunctionObjArgs(func, arg, NULL) Using the _PyObject_CallArg1() macro increases the usage of the C stack, which was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this issue.
2016-12-04Backed out changeset b9c9691c72c5Victor Stinner-1/+1
Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
2016-12-01Replace PyObject_CallFunction() with fastcallVictor Stinner-5/+5
Replace PyObject_CallFunction(func, "O", arg) and PyObject_CallFunction(func, "O", arg, NULL) with _PyObject_CallArg1(func, arg) Replace PyObject_CallFunction(func, NULL) with _PyObject_CallNoArg(func) _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack.
2016-12-01Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner-1/+1
* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507.
2016-11-20Added the const qualifier to char* variables that refer to readonly internalSerhiy Storchaka-1/+1
UTF-8 represenatation of Unicode objects.
2016-11-16Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka-3/+3
_PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka-3/+3
_PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.