The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix: module 'defusedxml' has no attribute 'ElementTree' (#31429) (#31431)
Sam Zhang2c4e0ab3bc8d
diff --git a/libs/core/langchain_core/output_parsers/xml.py b/libs/core/langchain_core/output_parsers/xml.pyindex c5a9527eb0..9f16319a1b 100644--- a/libs/core/langchain_core/output_parsers/xml.py+++ b/libs/core/langchain_core/output_parsers/xml.py@@ -51,7 +51,9 @@ class _StreamingParser:"""if parser == "defusedxml":try:- import defusedxml # type: ignore[import-untyped]+ from defusedxml.ElementTree import ( # type: ignore[import-untyped]+ XMLParser,+ )except ImportError as e:msg = ("defusedxml is not installed. "@@ -59,7 +61,7 @@ class _StreamingParser:"You can install it with `pip install defusedxml` ")raise ImportError(msg) from e- _parser = defusedxml.ElementTree.DefusedXMLParser(target=TreeBuilder())+ _parser = XMLParser(target=TreeBuilder())else:_parser = Noneself.pull_parser = ET.XMLPullParser(["start", "end"], _parser=_parser)@@ -207,7 +209,7 @@ class XMLOutputParser(BaseTransformOutputParser):# likely if you're reading this you can move them to the top of the fileif self.parser == "defusedxml":try:- from defusedxml import ElementTree+ from defusedxml import ElementTree # type: ignore[import-untyped]except ImportError as e:msg = ("defusedxml is not installed. "