Commit Graph

191 Commits

Author SHA1 Message Date
Serhiy Storchaka 7efaf95934 Issue25814: Propagate all errors from custom XML parser handlers
in ElementTree.iterparse().
2015-12-06 23:51:44 +02:00
Serhiy Storchaka 097a664f57 Issue #19687: Fixed possible integer overflows in ElementTree.
Based on patch by Christian Heimes.
2015-11-25 20:12:37 +02:00
Serhiy Storchaka dde0815c35 Issue #7990: dir() on ElementTree.Element now lists properties: "tag",
"text", "tail" and "attrib".  Original patch by Santoso Wijaya.
2015-11-25 15:28:13 +02:00
Serhiy Storchaka 3987fefd6f Issue #25691: Fixed crash on deleting ElementTree.Element attributes. 2015-11-23 08:47:26 +02:00
Serhiy Storchaka b6aa5375d5 Issue #25691: Fixed crash on deleting ElementTree.Element attributes. 2015-11-23 08:42:25 +02:00
Serhiy Storchaka 36e4f760f6 Issue #19687: Fixed memory leak on failed Element slice assignment.
Added new tests for Element slice assignments.
2015-11-22 12:30:28 +02:00
Serhiy Storchaka 04d759b1e4 Issue #19687: Fixed memory leak on failed Element slice assignment.
Added new tests for Element slice assignments.
2015-11-22 12:18:38 +02:00
Serhiy Storchaka 4a01cab898 Issue #19176: Fixed doctype() related bugs in C implementation of ElementTree.
A deprecation warning no longer issued by XMLParser subclass with default
doctype() method.  Direct call of doctype() now issues a warning.  Parser's
doctype() now is not called if target's doctype() is called.  Based on patch
by Martin Panter.
2015-06-29 23:08:52 +03:00
Serhiy Storchaka 05744ac6e0 Issue #19176: Fixed doctype() related bugs in C implementation of ElementTree.
A deprecation warning no longer issued by XMLParser subclass with default
doctype() method.  Direct call of doctype() now issues a warning.  Parser's
doctype() now is not called if target's doctype() is called.  Based on patch
by Martin Panter.
2015-06-29 22:35:58 +03:00
Serhiy Storchaka a2c145c2f3 Issue #24091: Fixed various crashes in corner cases in C implementation of
ElementTree.
2015-05-18 18:33:31 +03:00
Serhiy Storchaka 5bf3120e24 Issue #24091: Fixed various crashes in corner cases in C implementation of
ElementTree.
2015-05-18 18:29:33 +03:00
Larry Hastings dbfdc380df Issue #24001: Argument Clinic converters now use accept={type}
instead of types={'type'} to specify the types the converter accepts.
2015-05-04 06:59:46 -07:00
Serhiy Storchaka cb98556373 Issue #20159. Converted the _elementtree module to Argument Clinic. 2015-05-04 15:32:48 +03:00
Serhiy Storchaka 26861b0b29 Issue #23450: Fixed possible integer overflows. 2015-02-16 20:52:17 +02:00
Victor Stinner 706768c687 Issue #22156: Fix some "comparison between signed and unsigned integers"
compiler warnings in the Modules/ subdirectory.
2014-08-16 01:03:39 +02:00
Eli Bendersky 8148164353 Issue #19815: Fix segfault when parsing empty namespace declaration.
Based on patches by Christian Heimes and Vajrasky Kok
2013-11-28 06:35:40 -08:00
Eli Bendersky 4b79518f83 Fix indentation from previous commit 2013-11-28 06:33:21 -08:00
Eli Bendersky 5dd40e555b Issue #19815: Fix segfault when parsing empty namespace declaration.
Based on patches by Christian Heimes and Vajrasky Kok
2013-11-28 06:31:58 -08:00
Eli Bendersky 163d7f02a1 Cosmetic fixes 2013-11-24 06:55:04 -08:00
Victor Stinner 59799a8399 Don't use deprecated function PyUnicode_GET_SIZE()
Replace it with PyUnicode_GET_LENGTH() or PyUnicode_AsUnicodeAndSize()
2013-11-13 14:17:30 +01:00
Antoine Pitrou 4d397008cd Issue #19356: Avoid using a C variabled named "_self", it's a reserved word in some C compilers. 2013-10-23 19:21:55 +02:00
Antoine Pitrou 09fcb72048 Issue #19356: Avoid using a C variabled named "_self", it's a reserved word in some C compilers. 2013-10-23 19:20:21 +02:00
doko@ubuntu.com 9937155a1c - followup for issue #18997, make _clear_joined_ptr static. 2013-09-18 12:13:18 +02:00
doko@ubuntu.com 0648bf795c - followup for issue #18997, make _clear_joined_ptr static. 2013-09-18 12:12:28 +02:00
Eli Bendersky 12f18289c0 Merge for Issue #18997: Issue #18997: fix ElementTree crash with using pickle and __getstate__. 2013-09-13 06:27:52 -07:00
Eli Bendersky dd3661e782 Issue #18997: fix ElementTree crash with using pickle and __getstate__.
Based on report and initial patch from Germán M. Bravo
2013-09-13 06:24:25 -07:00
Eli Bendersky 6eb50b1f5b Use consistent style for else if / else 2013-08-24 15:17:08 -07:00
Eli Bendersky 532d03e547 Issue #15651: PEP 3121 refactoring for _elementtree
Patch by Antoine Pitrou (based on Robin Schreiber's original patch)
2013-08-10 08:00:39 -07:00
Christian Heimes 2ef710e40f Add missing check of PyDict_Update()'s return value in _elementtree.c
CID 719637
2013-07-20 15:12:19 +02:00
Christian Heimes 7ed4294d7f Add missing check of PyDict_Update()'s return value in _elementtree.c
CID 719637
2013-07-20 15:12:09 +02:00
Ronald Oussoren ced1226cce (3.3->default): #18480: Add missing PyType_Ready call to _elementtree extension 2013-07-19 11:14:05 +02:00
Ronald Oussoren 138d080a28 #18480: Add missing PyType_Ready call to _elementtree extension 2013-07-19 11:11:25 +02:00
Victor Stinner 3fd8cbd5e4 Issue #18408: Fix _elementtree.c, don't call Python function from an expat
handler if a Python exception is set
2013-07-18 22:46:14 +02:00
Victor Stinner d917dcbe5e Issue #18408: Fix constructors of _elementtree.c
* Use Py_DECREF() instead of PyObject_GC_Del() to release correctly all
  resources
* Raise MemoryError on memory allocation failure
2013-07-12 02:05:17 +02:00
Victor Stinner 81aac734e1 Issue #18408: Fix create_extra() of _elementtree.c, raise MemoryError on memory
allocation failure
2013-07-12 02:03:34 +02:00
Victor Stinner 71c8b7ec04 Issue #18408: Different fixes in _elementtree.c to handle correctly MemoryError
* create_new_element() initializes all attributes before handling errors,
   to fix a crash in the destructor
* create_new_element() calls PyObject_GC_Del() on error, instead of
  PyObject_Del(), because the object was created by PyObject_GC_New()
* subelement() now handles create_new_element() failure
* element_getattro() now handles element_get_text() failure
* makeuniversal() now handles PyBytes_FromStringAndSize() failure
2013-07-11 23:08:39 +02:00
Victor Stinner 4d46343340 Cleanup _elementtree.c 2013-07-11 23:05:03 +02:00
Victor Stinner 5f0af23f5e Issue #18408: _elementtree.c now handles create_extra() failure 2013-07-11 23:01:36 +02:00
Eli Bendersky 6dc32b34dd Issue #13612: handle unknown encodings without a buffer overflow.
This affects pyexpat and _elementtree. PyExpat_CAPI now exposes a new
function - DefaultUnknownEncodingHandler.

Based on a patch by Serhiy Storchaka.
2013-05-25 05:25:48 -07:00
Serhiy Storchaka 66d53fa9ad Issue #16986: ElementTree now correctly parses a string input not only when
an internal XML encoding is UTF-8 or US-ASCII.
2013-05-22 17:07:51 +03:00
Eli Bendersky 6a55dc3b4a Issue #17989: fix typo in error message 2013-05-19 16:59:59 -07:00
Eli Bendersky 08231a9c6a Issue #17901: fix TreeBuilder construction for an explicit element_factory=None
Based on report and patch by Aaron Oakley.
2013-05-18 15:47:16 -07:00
Eli Bendersky ef9683b73f Issue #17989: element_setattro returned incorrect error value.
This caused an exception to be raised later than expected.
2013-05-18 07:52:34 -07:00
Eli Bendersky 7b3022f24f Issue #13612: handle unknown encodings without a buffer overflow.
This affects pyexpat and _elementtree. PyExpat_CAPI now exposes a new
function - DefaultUnknownEncodingHandler.

Based on a patch by Serhiy Storchaka.
2013-05-25 05:27:10 -07:00
Serhiy Storchaka 447b6e3c6e Issue #16986: ElementTree now correctly parses a string input not only when
an internal XML encoding is UTF-8 or US-ASCII.
2013-05-22 17:21:06 +03:00
Eli Bendersky a369923cab Get rid of ugly code duplication for ElementTree.parse when the accelerator
is imported. Instead, ElementTree.parse can look for a special internal method
defined by the accelerator.
2013-05-19 18:47:23 -07:00
Eli Bendersky 3a36756ba1 Issue #17989: fix typo in error message 2013-05-19 17:00:28 -07:00
Eli Bendersky 3a4fbd8241 _elementtree.XMLParser._setevents should support any sequence, not just tuples
Also clean up some code around this
2013-05-19 09:01:49 -07:00
Eli Bendersky 20c1cdd64a Issue #17901: fix TreeBuilder construction for an explicit element_factory=None
Based on report and patch by Aaron Oakley.
2013-05-18 15:47:58 -07:00
Eli Bendersky 1a8c3e247a Issue #17989: element_setattro returned incorrect error value.
This caused an exception to be raised later than expected.
2013-05-18 07:53:47 -07:00
Eli Bendersky 45f3d2fff0 Revert c9674421d78e, leaving an additional comment 2013-04-24 05:34:07 -07:00
Eli Bendersky 1859fe80c4 Simplify the code of get_attrib_from_keywords somewhat. 2013-04-22 05:52:16 -07:00
Eli Bendersky ed8b86d323 Issue #17736: fix misleading comment in _elementtree.c
Patch by Jonas Wagner
2013-04-22 05:29:09 -07:00
Eli Bendersky d4cb4b7451 Issue #17736: fix misleading comment in _elementtree.c
Patch by Jonas Wagner
2013-04-22 05:25:25 -07:00
Eli Bendersky ddcc6798f6 Remove useless #define and #ifdefs 2013-04-20 06:36:43 -07:00
Eli Bendersky bf05df2396 Make license notices more consistent and remove old changelog.
Also remove unused macro.
2013-04-20 05:44:01 -07:00
Eli Bendersky 25771b3749 Issue #16922: fixed findtext() to return empty Unicode string instead of empty bytes object when there's no text.
Patch by Serhiy Storchaka.
2013-01-13 05:26:07 -08:00
Eli Bendersky 4583990143 Clean trailing whitespace in _elementtree.c 2013-01-13 05:14:47 -08:00
Eli Bendersky 799e3edaf7 Issue #16076: check for return value of PyTuple_New for args (following
Coverity report) and cleanup code.
2013-01-12 05:42:38 -08:00
Eli Bendersky b8f6dc855c Issue #16076: fix refleak in pickling of Element.
Thanks to Ezio Melotti and Daniel Shahaf for the patch.
2013-01-12 05:20:16 -08:00
Eli Bendersky e6174ca85e Issue #16913: Fix Element.itertext()'s handling of text with XML entities.
Patch by Serhiy Storchaka
2013-01-10 06:27:53 -08:00
Eli Bendersky 698bdb2a6c Issue #16076: make _elementtree.Element pickle-able in a way that is compatible
with the Python version of the class.

Patch by Daniel Shahaf.
2013-01-10 06:01:06 -08:00
Eli Bendersky a873690d2c The get() and iter() are now able to accept keyword arguments.
In conformance with the documentation and the Python version.
Patch by Franck Michea.
2013-01-05 06:26:39 -08:00
Antoine Pitrou ee329318db Issue #16089: Allow ElementTree.TreeBuilder to work again with a non-Element element_factory (fixes a regression in SimpleTAL). 2012-10-04 19:53:29 +02:00
Antoine Pitrou c194884983 Sanitize and modernize some of the _elementtree code (see issue #16089). 2012-10-01 23:40:37 +02:00
Antoine Pitrou ca8aa4acf6 Issue #15144: Fix possible integer overflow when handling pointers as integer values, by using Py_uintptr_t instead of size_t.
Patch by Serhiy Storchaka.
2012-09-20 20:56:47 +02:00
Eli Bendersky 7b31b1a2a4 Raise ImportError if pyexpat's version is incompatible 2012-07-21 20:32:39 +03:00
Eli Bendersky ef391ac982 Raise ImportError if pyexpat's version is incompatible 2012-07-21 20:28:46 +03:00
Eli Bendersky b48ff7fdda Merge for #14988 2012-07-17 14:25:14 +03:00
Eli Bendersky 66099b0cdc ISsue #14988: restore Python 2's behavior of raising ImportError when unable to load pyexpat, instead of a SystemError/RuntimeError 2012-07-17 14:20:38 +03:00
Martin v. Löwis bce166681c Issue #14055: Add __sizeof__ support to _elementtree. 2012-06-17 10:41:22 +02:00
Eli Bendersky 113da64259 Fix windows compilation problems caused by previous commit. 2012-06-15 07:52:49 +03:00
Eli Bendersky 64d11e60f2 Replace the iter/itertext methods of Element in _elementtree with true C implementations, instead of the bootstrapped Python code. In addition to being cleaner (removing the last remains of the bootstrapping code in _elementtree), this gives a 10x performance boost for iter() on large documents.
Also reorganized the tests a bit to be more robust.
2012-06-15 07:42:50 +03:00
Eli Bendersky c68e1368b5 Fix unterminated keyword array passed to PyArg_ParseTupleAndKeywords 2012-06-03 06:09:42 +03:00
Eli Bendersky 2b6b73e7e1 Issue #14007: implement doctype() method calling in XMLParser of _elementtree.
Includes exposing a doctype handler from expat through pyexpat.
2012-06-01 11:32:34 +03:00
Eli Bendersky 20d4174b3d We're always building _elementtree with USE_PYEXPAT_CAPI, so the #ifdefs in
the code are unnecessary.
2012-06-01 09:48:37 +03:00
Eli Bendersky 52467b167e Issue #14007: make XMLParser a real subclassable type exported from _elementtree. +cleanups 2012-06-01 07:13:08 +03:00
Eli Bendersky 48d358ba86 Issue #14007: implemented the 'element_factory' feature of TreeBuilder in
_elementtree, with a test.
2012-05-30 17:57:50 +03:00
Eli Bendersky 58d548dff1 Issue #14007: make TreeBuilder an actual type exposed from _elementtree, and subclassable. 2012-05-29 15:45:16 +03:00
Eli Bendersky 737b173355 Issue 14814: Add namespaces keyword arg to find(*) methods in _elementtree.
Add attrib keyword to Element and SubElement in _elementtree.
Patch developed with Ezio Melotti.
2012-05-29 06:02:56 +03:00
Eli Bendersky b20df95827 Issue #14849: setup Element data members to be assignable in subclasses 2012-05-20 06:33:29 +03:00
Eli Bendersky 828efdea56 Replace bootstrap imports with real C API calls. 2012-04-05 05:40:58 +03:00
Eli Bendersky 08b852970e Fix Windows compilation errors 2012-04-04 15:55:07 +03:00
Eli Bendersky ebf37a2ffb Fixes and enhancements to _elementtree:
* Fixed refleak problems when GC collection is run (see messages in
  issue #14065)
* Added weakref support to Element objects
2012-04-03 22:02:37 +03:00
Eli Bendersky 0192ba33b4 Issue #14065: Added cyclic GC support to ET.Element 2012-03-30 16:38:33 +03:00
Eli Bendersky 396e8fcf36 Issue #13782: streamline argument type-checking in ET.Element
append, extend and insert now consistently type-check their argument in both
the C and Python implementations, and raise TypeError for non-Element
argument.

Added tests
2012-03-23 14:24:20 +02:00
Eli Bendersky 5b77d81314 Issue #14207: the ParseError exception raised by _elementtree was made
consistent to the one raised by the Python module (the 'code' attribute
was added).

In addition, the exception is now documented.

Added a test to check that ParseError has the required attributes, and
threw away the equivalent doctest which is no longer required.
2012-03-16 08:20:05 +02:00
Eli Bendersky f996e775ea Closes Issue #14246: _elementtree parser will now handle io.StringIO 2012-03-16 05:53:30 +02:00
Eli Bendersky 865756a94c Issue #14178: Problem deleting slices with steps != +1 in the _elementtree module.
Fixed the problem and added some tests. Closes #14178
2012-03-09 13:38:15 +02:00
Florent Xicluna 50eee834fd Issue #14007: drop unused TreeBuilder().xml. 2012-03-05 10:28:42 +01:00
Eli Bendersky 092af1fc5c Issue #14128: Exposing Element as an actual type from _elementtree, rather than a factory function.
This makes the C implementation more aligned with the Python implementation.
Also added some tests to ensure that Element is now a type and that it can
be subclassed.
2012-03-04 07:14:03 +02:00
Florent Xicluna a72a98f24a Issue #13988: cElementTree is deprecated and the _elementtree accelerator is automatically used whenever available. 2012-02-13 11:03:30 +01:00
Florent Xicluna f4bdf4e478 Issue #13988: move the python bootstrap code to cElementTree.py, and remove obsolete code for Python 2.4 and 2.5. 2012-02-11 11:28:16 +01:00
Florent Xicluna f24e7e6c41 Merge 3.2: issue #2892 2011-11-01 23:33:14 +01:00
Florent Xicluna 91d5193b3a Closes #2892: preserve iterparse events in case of SyntaxError. 2011-11-01 23:31:09 +01:00
Martin v. Löwis bd928fef42 Rename _Py_identifier to _Py_IDENTIFIER. 2011-10-14 10:20:37 +02:00
Martin v. Löwis afe55bba33 Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
2011-10-09 10:38:36 +02:00
Martin v. Löwis d63a3b8beb Implement PEP 393. 2011-09-28 07:41:54 +02:00
Victor Stinner 499dfcf29d Issue #10833: Use PyUnicode_FromFormat() and PyErr_Format() instead of
PyOS_snprintf().
2011-03-21 13:26:24 +01:00
Victor Stinner bfc7bf06a6 _elementtree.c: remove trailing spaces 2011-03-21 13:23:42 +01:00