Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing with python3 + defusedxml #11

Open
xambroz opened this issue Oct 24, 2023 · 1 comment
Open

failing with python3 + defusedxml #11

xambroz opened this issue Oct 24, 2023 · 1 comment

Comments

@xambroz
Copy link

xambroz commented Oct 24, 2023

Hello,
tests (and the library) is failing when running on the python3 (3.11.6) and the defusedxml (0.7.1) is present (as this is the preffered xml library by the xlrd2). In defusedxml there is some strange situation where Element_has_iter is evaluated as false, but at the same time there is no getiterator() function.

self = <xlrd2.xlsx.X12Book object at 0x7f676b8b09d0>
stream = <zipfile.ZipExtFile name='xl\\workbook.xml' mode='r' compress_type=deflate>
heading = 'Workbook'

    def process_stream(self, stream, heading=None):
        if self.verbosity >= 2 and heading is not None:
            fprintf(self.logfile, "\n=== %s ===\n", heading)
        self.tree = ET.parse(stream)
        getmethod = self.tag2meth.get
>       for elem in self.tree.iter() if Element_has_iter else self.tree.getiterator():
E       AttributeError: 'ElementTree' object has no attribute 'getiterator'
            
xlrd2/xlsx.py:266: AttributeError

Full log from pytest:
error.txt

Workaround:
use xml.etree.cElementTree as default rather than defusedxml.ElementTree in xlrd2/xlsx.py

@xambroz
Copy link
Author

xambroz commented Oct 26, 2023

Related to this -
tiran/defusedxml#48
python-excel/xlrd#375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant