Re: [PythonReports-users] PythonReport - deprecation warning on et.getchildren
Brought to you by:
a1s
|
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
|