summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)Serhiy Storchaka2024-03-071-11/+5
|
* gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) ↵Sebastian Pipping2024-02-291-0/+35
| | | | | | | | | | | | | | | | | | | | | (GH-115623) 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 . ### Notes - Please treat as a security fix related to CVE-2023-52425. Includes code suggested-by: Snild Dolkow <snild@sony.com> and by core dev Serhiy Storchaka.
* gh-114569: Use PyMem_* APIs for most non-PyObject uses (#114574)Erlend E. Aasland2024-01-261-10/+13
| | | Fix usage in Modules, Objects, and Parser subdirectories.
* gh-103092: Make `_elementtree` module importable in sub-interpreters (#113434)Kirill Podoprigora2023-12-281-3/+1
| | | Enable imports of _elementtree module in sub-interpreters
* gh-111784: Fix two segfaults in the elementtree module (GH-113405)Kirill Podoprigora2023-12-241-2/+14
| | | | | | | | | | First fix resolve situation when pyexpat module (which contains expat_CAPI capsule) deallocates before _elementtree, so we need to hold a strong reference to pyexpat module to. Second fix resolve situation when module state is deallocated before deallocation of XMLParser instances, which uses module state to clear some stuff.
* gh-108511: Add C API functions which do not silently ignore errors (GH-109025)Serhiy Storchaka2023-09-171-2/+1
| | | | | | | | | Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
* gh-106869: Use new PyMemberDef constant names (#106871)Victor Stinner2023-07-251-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove '#include "structmember.h"'. * If needed, add <stddef.h> to get offsetof() function. * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Replace: * T_SHORT => Py_T_SHORT * T_INT => Py_T_INT * T_LONG => Py_T_LONG * T_FLOAT => Py_T_FLOAT * T_DOUBLE => Py_T_DOUBLE * T_STRING => Py_T_STRING * T_OBJECT => _Py_T_OBJECT * T_CHAR => Py_T_CHAR * T_BYTE => Py_T_BYTE * T_UBYTE => Py_T_UBYTE * T_USHORT => Py_T_USHORT * T_UINT => Py_T_UINT * T_ULONG => Py_T_ULONG * T_STRING_INPLACE => Py_T_STRING_INPLACE * T_BOOL => Py_T_BOOL * T_OBJECT_EX => Py_T_OBJECT_EX * T_LONGLONG => Py_T_LONGLONG * T_ULONGLONG => Py_T_ULONGLONG * T_PYSSIZET => Py_T_PYSSIZET * T_NONE => _Py_T_NONE * READONLY => Py_READONLY * PY_AUDIT_READ => Py_AUDIT_READ * READ_RESTRICTED => Py_AUDIT_READ * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
* gh-106320: Move private _PyHash API to the internal C API (#107026)Victor Stinner2023-07-221-0/+1
| | | | | * No longer export most private _PyHash symbols, only export the ones which are needed by shared extensions. * Modules/_xxtestfuzz/fuzzer.c now uses the internal C API.
* gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)Serhiy Storchaka2023-07-121-1/+1
|
* gh-106320: Remove private _PyImport C API functions (#106383)Victor Stinner2023-07-031-0/+5
| | | | | | * Remove private _PyImport C API functions: move them to the internal C API (pycore_import.h). * No longer export most of these private functions. * _testcapi avoids private _PyImport_GetModuleAttrString().
* gh-104922: remove PY_SSIZE_T_CLEAN (#106315)Inada Naoki2023-07-021-2/+0
|
* gh-106023: Update code using _PyObject_FastCall() (#106257)Victor Stinner2023-06-301-14/+8
| | | Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
* gh-105375: Improve error handling in _elementtree (#105591)Erlend E. Aasland2023-06-091-3/+7
| | | Fix bugs where exceptions could end up being overwritten.
* gh-92536: Remove PyUnicode_READY() calls (#105210)Victor Stinner2023-06-011-2/+0
| | | | Since Python 3.12, PyUnicode_READY() does nothing and always returns 0.
* GH-103092: isolate `_elementtree` (#104561)Kumar Aditya2023-05-161-43/+42
|
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-0/+3
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-92123: Adapt _elementtree to multi-phase init (PEP 489) (#101285)Erlend E. Aasland2023-01-241-82/+117
|
* GH-92123: Pass _elementtree state as parameter (#101189)Erlend E. Aasland2023-01-241-57/+73
|
* GH-92123: Store _elementtree state in type contexts (#101190)Erlend E. Aasland2023-01-231-17/+21
| | | | - add state pointer to TreeBuilderObject - add state pointer to XMLParserObject
* gh-83122: Deprecate testing element truth values in `ElementTree` (#31149)Jacob Walls2023-01-231-0/+18
| | | | | | | When testing element truth values, emit a DeprecationWarning in all implementations. This had emitted a FutureWarning in the rarely used python-only implementation since ~2.7 and has always been documented as a behavior not to rely on. Matching an element in a tree search but having it test False can be unexpected. Raising the warning enables making the choice to finally raise an exception for this ambiguous behavior in the future.
* GH-92123: Move _elementtree heap types to module state (#101187)Erlend E. Aasland2023-01-211-57/+91
|
* gh-92123: Convert `_elementtree` types to heap types (#99221)Erlend E. Aasland2023-01-201-229/+157
|
* GH-90699: Clear interned strings in `_elementtree` (#101185)Erlend E. Aasland2023-01-201-0/+10
|
* gh-99845: Use size_t type in __sizeof__() methods (#99846)Victor Stinner2022-11-301-6/+7
| | | | | | | | The implementation of __sizeof__() methods using _PyObject_SIZE() now use an unsigned type (size_t) to compute the size, rather than a signed type (Py_ssize_t). Cast explicitly signed (Py_ssize_t) values to unsigned type (Py_ssize_t).
* gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)Victor Stinner2022-11-231-2/+1
| | | Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
* gh-99300: Replace Py_INCREF() with Py_NewRef() in _elementtree.c (#99696)Victor Stinner2022-11-221-69/+36
| | | | | | | * Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef() in Modules/_elementtree.c. * Make reference counting more explicit: don't steal implicitly a reference on PyList_SET_ITEM(), use Py_NewRef() instead. * Replace PyModule_AddObject() with PyModule_AddObjectRef().
* gh-99537: Use Py_SETREF() function in C code (#99656)Victor Stinner2022-11-221-4/+2
| | | | | | | | | | | | | | | Fix potential race condition in code patterns: * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);" * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);" Other changes: * Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);" * Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);" * And remove the "old" variable.
* gh-99300: Replace Py_INCREF() with Py_NewRef() (#99513)Victor Stinner2022-11-161-8/+4
| | | | Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
* gh-99300: Use Py_NewRef() in Modules/_elementtree.c (#99438)Victor Stinner2022-11-131-82/+37
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in Modules/_elementtree.c.
* GH-90699: Remove `_Py_IDENTIFIER` usage from `_elementtree` module (GH-99012)Kumar Aditya2022-11-021-25/+59
|
* gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742)Serhiy Storchaka2022-06-141-6/+2
| | | | | | It combines PyImport_ImportModule() and PyObject_GetAttrString() and saves 4-6 lines of code on every use. Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
* gh-89653: Use int type for Unicode kind (#92704)Victor Stinner2022-05-131-1/+1
| | | | Use the same type that PyUnicode_FromKindAndData() kind parameter type (public C API): int.
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-1/+1
| | | | | | | | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c")
* Remove an old, elementtree-specific leak detector (GH-31811)Oleg Iarygin2022-03-111-13/+0
|
* bpo-45948: Remove constructor discrepancy in C version of ↵Jacob Walls2022-02-121-3/+3
| | | | | ElementTree.XMLParser (GH-31152) Both implementations accept target=None now.
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-27946: Fix possible crash in ElementTree.Element (GH-29915)Serhiy Storchaka2021-12-051-13/+10
| | | | | Getting an attribute via attrib.get() simultaneously with replacing the attrib dict can lead to access to deallocated dict.
* Update URLs in comments and metadata to use HTTPS (GH-27458)Noah Kantrowitz2021-07-301-1/+1
|
* bpo-39573: Use the Py_TYPE() macro (GH-21433)Victor Stinner2020-07-101-1/+1
| | | Replace obj->ob_type with Py_TYPE(obj).
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+1
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-31758: Prevent crashes when using an uninitialized ↵Oren Milman2020-04-121-0/+24
| | | | _elementtree.XMLParser object (GH-3997)
* bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. ↵Serhiy Storchaka2020-04-121-1/+1
| | | | (GH-19472)
* bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode ↵Serhiy Storchaka2020-04-111-1/+1
| | | | data. (GH-19345)
* bpo-40024: Update _elementtree to use PyModule_AddType() (GH-19205)Dong-hee Na2020-03-291-8/+14
|
* bpo-39968: Convert extension modules' macros of get_module_state() to inline ↵Hai Shi2020-03-161-4/+10
| | | | functions (GH-19017)
* bpo-39822: Use NULL instead of None for empty attrib in Element. (GH-18735)Serhiy Storchaka2020-03-091-40/+32
|
* bpo-39903: Fix double decref in _elementtree.Element.__getstate__ (GH-18850)Serhiy Storchaka2020-03-091-26/+17
|
* bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601)Andy Lester2020-03-041-1/+1
|
* bpo-39495: Remove default value from C impl of TreeBuilder.start (GH-18275)Shantanu2020-03-021-2/+2
|
* bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)Dong-hee Na2020-02-171-1/+1
|