[Yum-devel] [PATCH] catch XML parse errors. BZ 825811, 830739.

Zdeněk Pavlas zpavlas at redhat.com
Tue Jun 19 13:53:24 UTC 2012


Print XML errors to stderr instead of terminating.
Based on yum.update_md.safe_iterparse().
---
 langpacks.py |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/langpacks.py b/langpacks.py
index 6a58a7c..5ac3ab3 100644
--- a/langpacks.py
+++ b/langpacks.py
@@ -28,13 +28,14 @@ import os
 import rpm
 
 import yum.Errors
-
-try:
-    from xml.etree import cElementTree
-except ImportError:
-    import cElementTree
-
-iterparse = cElementTree.iterparse
+import yum.misc, sys
+
+def iterparse(filename):
+    try:
+        for e in yum.misc.cElementTree_iterparse(filename):
+            yield e
+    except SyntaxError, e:
+        print >>sys.stderr, '%s: %s' % (filename, str(e))
 
 requires_api_version = '2.5'
 plugin_type = TYPE_CORE
-- 
1.7.4.4



More information about the Yum-devel mailing list