Thread: [PythonReports-users] PythonReport - deprecation warning on et.getchildren
Brought to you by:
a1s
From: Werner F. B. <wer...@fr...> - 2012-12-20 16:27:58
|
Hi, Before I forget about this one. Error saving template file This method will be removed in future versions. Use 'list(elem)' or iteration over elem instead. I see the above for: builder.find_layout_parents datatypes.writexml In both cases I could just change from: for _child in element.getchildren(): to: for _child in element: Is this fine or do you prefer a different fix? There are some more calls to et.getchildren which I didn't hit, where I think the "list(elem)" solution should be used. Werner |
From: alexander s. <al...@go...> - 2012-12-20 17:43:04
|
Werner F. Bruhin wrote, at 20.12.2012 18:29: > > 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. > I see the above for: > > builder.find_layout_parents > datatypes.writexml > > In both cases I could just change from: > > for _child in element.getchildren(): > > to: > > for _child in element: > > Is this fine or do you prefer a different fix? 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. There is getiterator() method, but it returns something completely different... So, unless there is solution acceptable for 2.4 the easiest way would be to ignore this warning (maybe add a filtering code to start-up script). I don't expect the deprecated method disappear until the end of Python2 life time, and for Python3 there is no wx. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2012-12-20 18:55:54
|
Found it how to catch, can't use "with", so this does the trick for me: warnings.simplefilter("ignore") self.env = EditorEnvironment(EditorForm(None)) Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-20 18:56:34
|
Hi Alex, (send again, but to list this time) On 20/12/2012 18:41, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 20.12.2012 18:29: >> 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\editor\environment.py", line 192, in report_save self.report_save_file(self.filename) File "c:\Python27\lib\site-packages\PythonReports\editor\environment.py", line 181, in report_save_file templatesaver.save_template_file(_report, filename) File "c:\Python27\lib\site-packages\PythonReports\editor\templatesaver.py", line 67, in save_template_file _xml_template.write(file_name) File "c:\Python27\lib\site-packages\PythonReports\datatypes.py", line 1315, in write self.root_validator.writexml(file, self._root, encoding) 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. I tried using catch_warnings, but I must do something wrong as it still hits the error. with warnings.catch_warnings(): warnings.simplefilter("ignore") self.env = EditorEnvironment(EditorForm(None)) > 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. Do you see what I am doing wrong with the catch_warnings? > > There is getiterator() method, but it returns something completely > different... > > So, unless there is solution acceptable for 2.4 the easiest way would be > to ignore this warning (maybe add a filtering code to start-up script). > > I don't expect the deprecated method disappear until the end of Python2 > life time, and for Python3 there is no wx. There are wxPython Phoenix builds:) for Python 3.x, but yes they are not yet ready for real usage. See you Werner |
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. |
From: Werner F. B. <wer...@fr...> - 2012-12-21 07:09:41
|
Hi Alex, On 20/12/2012 20:54, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 20.12.2012 20:57: ... >> 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. I don't know/see how to fix it. Will you report it to ElementTree? I am o.k. with just doing the "warnings.simplefilter("ignore")" just before calling the designer and then I reset the warnings when it is closing. Have a good weekend Werner |
From: alexander s. <al...@go...> - 2012-12-21 07:17:01
|
On 21.12.2012 9:10, Werner F. Bruhin wrote: > >>> 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. > I don't know/see how to fix it. Please try this: http://pythonreports.bzr.sourceforge.net/bzr/pythonreports/revision/236 > Will you report it to ElementTree? No. Best wishes, alex. |