colcon / colcon-cmake

Extension for colcon to support CMake packages
http://colcon.readthedocs.io
Apache License 2.0
16 stars 25 forks source link

Fix crash under Python3.9 #78

Closed rotu closed 4 years ago

rotu commented 4 years ago

As per docs:

https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren

getchildren()
    Deprecated since version 3.2, will be removed in version 3.9: Use list(elem) or iteration.
dirk-thomas commented 4 years ago

Thanks for reporting this. Based on the referenced documentation wouldn't it be sufficient to replace the following line:

https://github.com/colcon/colcon-cmake/blob/8a2ddbdb90dd5542f0f9bf10e7b89ccf6c7f48b3/colcon_cmake/test_result/ctest.py#L62

with:

children = list(root)
rotu commented 4 years ago

Yes, it would. I find this way is more idiomatic and it removes the repetition of "children[0]". You can think of it as children = list(root); testing = children[0].

dirk-thomas commented 4 years ago

I rather keep the diff minimal (7922b617655884ae9538b68291e6eebf863d8d86) and the code more readable (compared to the proposed implicit conversion in [testing] = root). I also don't think the repetition of children[0] is worth introducing another variable.