Changeset 2711:113988ef6cf0 in livinglogic.python.xist

Show
Ignore:
Timestamp:
06/22/07 18:38:16 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Raise error in tonode() instead of issueing a warning.

Remove second implementation for Attrs.iter() (which was wrong).

Raise an error for Attrs passed to tonode().

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/xsc.py

    r2710 r2711  
    7070    if isinstance(value, Node): 
    7171        if isinstance(value, Attrs): 
    72             raise TypeError("cannot convert %r" % value) 
     72            raise IllegalObjectError(value) 
    7373        # we don't have to turn an Attr into a Frag, because this will be done once the Attr is put back into the tree 
    7474        return value 
     
    8787        except TypeError: 
    8888            pass 
    89     warnings.warn(IllegalObjectWarning(value)) # none of the above, so we report it and maybe throw an exception 
    90     return Null 
     89    raise IllegalObjectError(value) # none of the above => bail out 
    9190 
    9291 
     
    463462 
    464463 
    465 class IllegalObjectWarning(Warning): 
    466     """ 
    467     Warning that is issued when &xist; finds an illegal object in its object tree. 
     464class IllegalObjectError(TypeError): 
     465    """ 
     466    Exception that is raised when an &xist; constructor gets passed an unconvertable object. 
    468467    """ 
    469468 
     
    472471 
    473472    def __str__(self): 
    474         return "an illegal object %r of type %s has been found in the XIST tree." % (self.object, type(self.object).__name__) 
     473        return "can't convert object %r of type %s to an XIST node" % (self.object, type(self.object).__name__) 
    475474 
    476475 
     
    26612660            loc = "" 
    26622661        return "<%s.%s attrs %s%s at 0x%x>" % (self.__class__.__module__, self.__fullname__, info, loc, id(self)) 
    2663  
    2664     def __iter__(self): 
    2665         return self.itervalues() 
    26662662 
    26672663 
  • test/test_xist.py

    r2710 r2711  
    6262        node.append(html.p.Attrs.id(7)) 
    6363        check_lenunicode(node, 7, u"1234567") 
    64         py.test.raises(TypeError, node.append, xml.Attrs(lang="de")) 
     64        py.test.raises(TypeError, node.append, xml.Attrs(lang=8)) 
    6565 
    6666