summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-31758: Prevent crashes when using an uninitialized ↵Miss Islington (bot)2020-04-121-0/+24
| | | | | _elementtree.XMLParser object (GH-3997) (GH-19485) (cherry picked from commit 402e1cdb132f384e4dcde7a3d7ec7ea1fc7ab527)
* bpo-39903: Fix double decref in _elementtree.Element.__getstate__ (GH-18850)Miss Islington (bot)2020-03-091-26/+17
| | | | | (cherry picked from commit 88944a44aa84b0f3674939019b1befbc7a9dc874) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.8] bpo-37206: Unrepresentable default values no longer represented as ↵Serhiy Storchaka2019-09-141-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>
* [3.8] bpo-37399: Correctly attach tail text to the last element/comment/pi ↵Stefan Behnel2019-07-241-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.
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-8/+8
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375)Zackery Spytz2019-05-171-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>
* bpo-35983: skip trashcan for subclasses (GH-11841)Jeroen Demeyer2019-05-101-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.
* bpo-36811: Fix a C compiler warning in _elementtree.c. (GH-13109)Stefan Behnel2019-05-061-1/+1
|
* bpo-28238: Implement "{*}tag" and "{ns}*" wildcard tag selection support for ↵Stefan Behnel2019-05-031-1/+14
| | | | ElementPath, and extend the surrounding tests and docs. (GH-12997)
* bpo-36676: Namespace prefix aware parsing support for the ET.XMLParser ↵Stefan Behnel2019-05-011-19/+121
| | | | | target (GH-12885) * bpo-36676: Implement namespace prefix aware parsing support for the XMLParser target in ElementTree.
* bpo-36673: Implement comment/PI parsing support for the TreeBuilder in ↵Stefan Behnel2019-05-011-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).
* bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)Serhiy Storchaka2019-02-251-7/+13
|
* bpo-35502: Fix reference leaks in ElementTree.TreeBuilder. (GH-11170)Serhiy Storchaka2018-12-181-0/+5
|
* bpo-35454: Fix miscellaneous minor issues in error handling. (#11077)Serhiy Storchaka2018-12-111-1/+4
| | | | | | * bpo-35454: Fix miscellaneous minor issues in error handling. * Fix a null pointer dereference.
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-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.
* Fix error handling bugs in _elementtree.c. (GH-10060)Zackery Spytz2018-10-231-11/+11
| | | | References could leak, NULL could be dereferenced, and the Expat parser could be double freed when some errors raised.
* bpo-35013: Add more type checks for children of Element. (GH-9944)Serhiy Storchaka2018-10-191-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.
* bpo-35008: Fix possible leaks in Element.__setstate__(). (GH-9924)Serhiy Storchaka2018-10-181-31/+64
| | | | | C implementation of xml.etree.ElementTree.Element.__setstate__() leaked references to children when called for already initialized element.
* bpo-34941: Fix searching Element subclasses. (GH-9766)Serhiy Storchaka2018-10-141-12/+13
| | | | Methods find(), findtext() and findall() of xml.etree.ElementTree.Element were not able to find chldren which are instances of Element subclasses.
* bpo-34739: Get rid of tp_getattro in xml.etree.ElementTree.XMLParser. (GH-9420)Serhiy Storchaka2018-10-041-24/+19
| | | Use tp_members and tp_getset instead.
* bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146)Christian Heimes2018-09-181-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
* bpo-34218: Fix a leak in _elementtree.c introduced in GH-6769. (GH-8460)Serhiy Storchaka2018-07-251-0/+1
|
* bpo-29209: Remove old-deprecated features in ElementTree. (GH-6769)Serhiy Storchaka2018-07-241-73/+14
| | | | | Also make getchildren() and getiterator() emitting a DeprecationWarning instead of PendingDeprecationWarning.
* bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka2017-12-151-1/+1
| | | | arguments. (#4746)
* bpo-31728: Prevent crashes in _elementtree due to unsafe cleanup of ↵Oren Milman2017-10-101-34/+28
| | | | Element.text and Element.tail (#3924)
* bpo-31499, xml.etree: Fix xmlparser_gc_clear() crash (#3641)Victor Stinner2017-09-181-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>
* bpo-31455: Fix an assertion failure in ElementTree.XMLParser(). (#3545)scoder2017-09-141-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.
* bpo-31428: Prevent raising a SystemError in case the memo arg of ↵Oren Milman2017-09-121-4/+5
| | | | ElementTree.Element.__deepcopy__() isn't a dictionary. (#3512)
* bpo-31095: fix potential crash during GC (GH-2974)INADA Naoki2017-08-241-1/+3
|
* bpo-30892: Fix _elementtree module initialization (#2647)Victor Stinner2017-07-101-0/+5
| | | | Handle getattr(copy, 'deepcopy') error in _elementtree module initialization.
* bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)Serhiy Storchaka2017-07-031-1/+1
| | | | | the bare METH_FASTCALL be used for functions with positional-only parameters.
* bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096)Serhiy Storchaka2017-04-191-2/+2
| | | | | | raised an error. Replace them with using concrete types API that never fails if appropriate.
* Expand the PySlice_GetIndicesEx macro. (#1023)Serhiy Storchaka2017-04-081-6/+6
|
* bpo-29204: Emit warnings for already deprecated ElementTree features. (#773)Serhiy Storchaka2017-03-301-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.
* bpo-27863: Fixed multiple crashes in ElementTree. (#765)Serhiy Storchaka2017-03-301-48/+52
|
* Run Argument Clinic: METH_VARARGS=>METH_FASTCALLVictor Stinner2017-01-171-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.
* Merge from 3.6.Serhiy Storchaka2016-12-211-0/+2
|\
| * Merge from 3.5.Serhiy Storchaka2016-12-211-0/+2
| |\
| | * Issue #28871: Fixed a crash when deallocate deep ElementTree.Serhiy Storchaka2016-12-211-0/+2
| | |
* | | Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka2016-12-161-1/+1
| | | | | | | | | | | | dict.
* | | Use PyObject_CallFunctionObjArgs()Victor Stinner2016-12-091-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.
* | | Use _PyObject_CallMethodIdObjArgs() in _elementtreeVictor Stinner2016-12-091-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.
* | | Issue #28858: Remove _PyObject_CallArg1() macroVictor Stinner2016-12-051-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.
* | | Backed out changeset b9c9691c72c5Victor Stinner2016-12-041-1/+1
| | | | | | | | | | | | | | | | | | Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
* | | Replace PyObject_CallFunction() with fastcallVictor Stinner2016-12-011-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.
* | | Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner2016-12-011-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.
* | | Added the const qualifier to char* variables that refer to readonly internalSerhiy Storchaka2016-11-201-1/+1
|/ / | | | | | | UTF-8 represenatation of Unicode objects.
* | Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-3/+3
|\ \ | |/ | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
| * Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-3/+3
| | | | | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
* | Fix xml.etree.ElementTree.Element.getiterator()Victor Stinner2016-09-291-1/+1
| | | | | | | | | | Issue #28314: Fix function declaration (C flags) for the getiterator() method of xml.etree.ElementTree.Element.