mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
[3.13] gh-135640: Adds more type checking to ElementTree (GH-135643) (GH-136226)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
(cherry picked from commit e0245c789f
)
Co-authored-by: Kira <kirawhoprograms@fastmail.com>
This commit is contained in:
parent
d80df8c1a5
commit
1de8fc3e4b
3 changed files with 39 additions and 2 deletions
|
@ -523,7 +523,9 @@ class ElementTree:
|
|||
|
||||
"""
|
||||
def __init__(self, element=None, file=None):
|
||||
# assert element is None or iselement(element)
|
||||
if element is not None and not iselement(element):
|
||||
raise TypeError('expected an Element, not %s' %
|
||||
type(element).__name__)
|
||||
self._root = element # first node
|
||||
if file:
|
||||
self.parse(file)
|
||||
|
@ -539,7 +541,9 @@ class ElementTree:
|
|||
with the given element. Use with care!
|
||||
|
||||
"""
|
||||
# assert iselement(element)
|
||||
if not iselement(element):
|
||||
raise TypeError('expected an Element, not %s'
|
||||
% type(element).__name__)
|
||||
self._root = element
|
||||
|
||||
def parse(self, source, parser=None):
|
||||
|
@ -705,6 +709,8 @@ class ElementTree:
|
|||
of start/end tags
|
||||
|
||||
"""
|
||||
if self._root is None:
|
||||
raise TypeError('ElementTree not initialized')
|
||||
if not method:
|
||||
method = "xml"
|
||||
elif method not in _serialize:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue