Re: [PythonReports-users] PythonReport - deprecation warning on et.getchildren
Brought to you by:
a1s
From: alexander s. <al...@go...> - 2012-12-21 06:58:17
|
Werner F. Bruhin wrote, at 20.12.2012 20:57: > >>> Error saving template file This method will be removed in future >>> versions. Use 'list(elem)' or iteration over elem instead. >> >> You mean, warning; this shouldn't be error. > > It is a warning, but it damages the file I try to save, i.e. it has "0" > bytes after, if I try to reopen it I get "Invalid template file". Don't > understand why, still searching. > > This is the traceback I see in WingIDE: > > Error saving template file This method will be removed in future > versions. Use 'list(elem)' or iteration over elem instead. > Traceback (most recent call last): > File "c:\Python27\lib\site-packages\PythonReports\editor\toolbar.py", > line 47, in OnSave > self.app.pyr_editor_env.report_save() > File "c:\Python27\lib\site-packages\PythonReports\datatypes.py", line > 1070, in writexml > for _child in element.getchildren(): > File "c:\Python27\lib\xml\etree\ElementTree.py", line 350, in getchildren > DeprecationWarning, stacklevel=2 > DeprecationWarning: This method will be removed in future versions. Use > 'list(elem)' or iteration over elem instead. Right. That's error, and it has to be fixed. >> Sorry, no. The iterator interface is not documented prior to 2.7, and I >> also do not see it in the xml/etree/ElementTree.py source. And I don't >> grok how the list() trick could possibly work. > > I was going to suggest "if sys.version_info > 2.7:" but if the list > trick won't work then that is not an option. I mean, converting to list shouldn't work without iterator. Adding a check for Python version is an obvious work around, but that would be quite ugly thing to add in five places where .getchildren() is needed. Best wishes, alex. |