diff emeraldtree/ElementTree.py @ 50:d3767204a325

ElementTree - Bail out if attrib argument is no dict, force uri argument to be unicode
author Bastian Blank <bblank@thinkmo.de>
date Sun, 17 Aug 2008 21:44:51 +0200
parents 547347034e65
children d071598a93ef
line wrap: on
line diff
--- a/emeraldtree/ElementTree.py	Tue Aug 12 13:11:06 2008 +0200
+++ b/emeraldtree/ElementTree.py	Sun Aug 17 21:44:51 2008 +0200
@@ -185,7 +185,13 @@
         raise RuntimeError('The tail argument is not supported')
 
     def __init__(self, tag, attrib=None, children=(), **extra):
-        attrib = attrib and attrib.copy() or {}
+        if attrib:
+            if isinstance(attrib, dict):
+                attrib = attrib.copy()
+            else:
+                raise TypeError('attrib')
+        else:
+            attrib = {}
         attrib.update(extra)
         self.tag = tag
         self.attrib = attrib
@@ -495,6 +501,7 @@
             name = name[i + 1:]
 
         if uri is not None:
+            uri = unicode(uri)
             text = '{' + uri + '}' + name
 
         ret = unicode.__new__(cls, text)