Coverage for adhoc-cicd-odoo-odoo / odoo / _monkeypatches / xlrd.py: 56%
9 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:05 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:05 +0000
1def patch_module():
2 try:
3 from xlrd import xlsx # noqa: PLC0415
4 except ImportError:
5 xlsx = None
6 else:
7 from lxml import etree # noqa: PLC0415
8 # xlrd.xlsx supports defusedxml, defusedxml's etree interface is broken
9 # (missing ElementTree and thus ElementTree.iter) which causes a fallback to
10 # Element.getiterator(), triggering a warning before 3.9 and an error from 3.9.
11 #
12 # Historically we had defusedxml installed because zeep had a hard dep on
13 # it. They have dropped it as of 4.1.0 which we now require (since 18.0),
14 # but keep this patch for now as Odoo might get updated in a legacy env
15 # which still has defused.
16 #
17 # Directly instruct xlsx to use lxml as we have a hard dependency on that.
18 xlsx.ET = etree
19 xlsx.ET_has_iterparse = True
20 xlsx.Element_has_iter = True