Python 2.7: elem.getiterator # cET compatibility AttributeError: ‘NoneType’ object has no attribute ‘getiterator’

This issue was occuring Gradle Wrapper build samples. Issue was related to python. Following versions of python software currently installed in my system.

python version: 2.7.18 (as it is required for the project).

Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]

Traceback (most recent call last):
`Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]

Traceback (most recent call last):

Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]

Traceback (most recent call last):
  File "C:\Users\narmadha.jeyaratnam\Perforce\mob-auto.prj.audi-hcp3.mainline.narmadha.jeyaratnam_EUR-F3Y63J3.Audi-HCP3-Mainline_ac.c\sw\cdfw-service-android\..\../Tools/FunctionBlockFramework/tools/fbpj_generate_file_list.py", line 250, in <module>
    filelists["fn_co"] = generateIncludeFileListWithOverridesFNs(fili_fb_co, ".*\.gdml$")
  File "C:\Users\narmadha.jeyaratnam\Perforce\mob-auto.prj.audi-hcp3.mainline.narmadha.jeyaratnam_EUR-F3Y63J3.Audi-HCP3-Mainline_ac.c\sw\cdfw-service-android\..\../Tools/FunctionBlockFramework/tools/fbpj_generate_file_list.py", line 60, in generateIncludeFileListWithOverridesFNs
    et_proto_str = ET.tostring(getElementTreeFromFile(os.path.join(folderlist[0], file)))
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 1126, in tostring
    ElementTree(element).write(file, encoding, method=method)
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 817, in write
    self._root, encoding, default_namespace
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 876, in _namespaces
    iterate = elem.getiterator # cET compatibility
AttributeError: 'NoneType' object has no attribute 'getiterator'

As the project required python 2.7 version to compile the embedded tools, unable to try with different compatible versions.
For the versions above python 3 this issue was not reproducible.
Any solution to make it compatible with python 2.7?

Leave a Comment