| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| The :mod:`xml.etree.ElementTree` module now emits :exc:`DeprecationWarning` | ||
| when testing the truth value of an :class:`xml.etree.ElementTree.Element`. | ||
| Before, the Python implementation emitted :exc:`FutureWarning`, and the C | ||
| implementation emitted nothing. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1449,6 +1449,23 @@ element_getitem(PyObject* self_, Py_ssize_t index) | |
| return Py_NewRef(self->extra->children[index]); | ||
| } | ||
|
|
||
| static int | ||
| element_bool(PyObject* self_) | ||
| { | ||
| ElementObject* self = (ElementObject*) self_; | ||
| if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| "Testing an element's truth value will raise an exception " | ||
| "in future versions. Use specific 'len(elem)' or " | ||
| "'elem is not None' test instead.", | ||
| 1) < 0) { | ||
| return -1; | ||
| }; | ||
| if (self->extra ? self->extra->length : 0) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
|
Comment thread
Comment on lines
+1463
to
+1466
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt could be simply return self->extra && self->extra->length;
Sorry, something went wrong.
All reactions
|
||
| } | ||
|
|
||
| /*[clinic input] | ||
| _elementtree.Element.insert | ||
|
|
||
| Expand Down Expand Up | @@ -4156,6 +4173,7 @@ static PyType_Slot element_slots[] = { | |
| {Py_sq_length, element_length}, | ||
| {Py_sq_item, element_getitem}, | ||
| {Py_sq_ass_item, element_setitem}, | ||
| {Py_nb_bool, element_bool}, | ||
| {Py_mp_length, element_length}, | ||
| {Py_mp_subscript, element_subscr}, | ||
| {Py_mp_ass_subscript, element_ass_subscr}, | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.