Skip to content

BUG: jobInfo is falsey when it holds only child elements (with astropy/astropy#20509) #788

Closed

Description

@jdavies-st

bool(job.jobinfo) is False for a jobInfo that holds only child elements when pyvo runs against astropy/astropy#20509, which we are hoping to get into astropy 8.1. The if job.jobinfo: pattern shown in docs/io/uws.rst then skips a populated jobInfo, and four doctest examples in that file fail. Once the astropy PR is merged, pyvo's devdeps CI job will pick it up from the nightly wheels and fail too.

Reproducer

Based on the failing doctest docs/io/uws.rst:239: DocTestFailure:

from io import BytesIO
from pyvo.io.uws import parse_job

xml = b"""<?xml version="1.0"?>
<uws:job xmlns:uws="http://www.ivoa.net/xml/UWS/v1.0" version="1.1">
  <uws:jobId>1</uws:jobId>
  <uws:phase>COMPLETED</uws:phase>
  <uws:jobInfo>
    <rowsReturned>1234</rowsReturned>
    <nodeId>compute-node-03</nodeId>
  </uws:jobInfo>
</uws:job>
"""

job = parse_job(BytesIO(xml))
print(bool(job.jobinfo), repr(job.jobinfo.text), str(job.jobinfo))

The printed output using astropy main

True 'compute-node-03' compute-node-03

and astropy/astropy#20509:

False None <jobInfo with 2 children>

Cause

ExtensibleUWSElement gets its truthiness from ContentMixin.__bool__, which returns bool(self.content). content is set from the text that astropy.utils.xml.iterparser.get_xml_iterator gives with the element's end event.

Until now, astropy's XML parser never cleared its text buffer when an element ended, so every end event repeated the text of the last nested element. In the example above, </uws:jobInfo> carried compute-node-03, even though that text belongs only to the parent. That is why bool(job.jobinfo) was True, and also why .text and str() of an element with children return the text of its last child. The repeated text is what made reading large BINARY2 VOTables use so much memory (astropy/astropy#8946), so astropy/astropy#20509 removes it, and an element that holds only child elements now ends with empty text.

The .text and str() results with astropy/astropy#20509 look like the intended ones. Only the truthiness needs a change in pyvo. So perhaps give ExtensibleUWSElement its own __bool__ method that is true when the element has child elements or text, and make it not depend on the end-event text. That should work with astropy main and the PR.

Activity

  1. changed the title [-]BUG: jobInfo is falsy when it holds only child elements (with astropy/astropy#20509)[/-] [+]BUG: jobInfo is falsey when it holds only child elements (with astropy/astropy#20509)[/+] on Oct 14, 2026
  2. added this to the v1.10.0 milestone on Oct 14, 2026
  3. modified the milestones: v1.10.0, on Oct 14, 2026
  4. removed this from the milestone on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions