Browse Source

From Sidnei: Import iterparse from xml.etree when available (eg: Python 2.6).

(see http://lists.supervisord.org/pipermail/supervisor-users/2010-June/000598.html).
Chris McDonough 15 years ago
parent
commit
0ffcaa8ec2
2 changed files with 15 additions and 4 deletions
  1. 2 0
      CHANGES.txt
  2. 13 4
      src/supervisor/xmlrpc.py

+ 2 - 0
CHANGES.txt

@@ -1,5 +1,7 @@
 Next release
 Next release
 
 
+  - Import iterparse from xml.etree when available (eg: Python 2.6).
+
   - When parsing "environment=" in the config file, changes introduced in
   - When parsing "environment=" in the config file, changes introduced in
     3.0a8 prevented Supervisor from parsing some characters commonly
     3.0a8 prevented Supervisor from parsing some characters commonly
     found in paths unless quoting was used as in this example:
     found in paths unless quoting was used as in this example:

+ 13 - 4
src/supervisor/xmlrpc.py

@@ -527,8 +527,19 @@ def gettags(comment):
 
 
     return tags
     return tags
 
 
+
 try:
 try:
-    from cElementTree import iterparse
+    # Python 2.6 contains a version of cElementTree inside it.
+    from xml.etree.ElementTree import iterparse
+except ImportError:
+    try:
+        # Failing that, try cElementTree instead.
+        from cElementTree import iterparse
+    except ImportError:
+        iterparse = None
+
+
+if iterparse is not None:
     import datetime, time
     import datetime, time
     from base64 import decodestring
     from base64 import decodestring
 
 
@@ -565,7 +576,5 @@ try:
             elif elem.tag == "params":
             elif elem.tag == "params":
                 params = tuple([v.text for v in elem])
                 params = tuple([v.text for v in elem])
         return params, method
         return params, method
-
-except ImportError:
+else:
     loads = None
     loads = None
-