Changeset 2711:113988ef6cf0 in livinglogic.python.xist
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
r2710
|
r2711
|
|
70 | 70 | if isinstance(value, Node): |
71 | 71 | if isinstance(value, Attrs): |
72 | | raise TypeError("cannot convert %r" % value) |
| 72 | raise IllegalObjectError(value) |
73 | 73 | # 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 |
74 | 74 | return value |
… |
… |
|
87 | 87 | except TypeError: |
88 | 88 | 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 |
91 | 90 | |
92 | 91 | |
… |
… |
|
463 | 462 | |
464 | 463 | |
465 | | class IllegalObjectWarning(Warning): |
466 | | """ |
467 | | Warning that is issued when &xist; finds an illegal object in its object tree. |
| 464 | class IllegalObjectError(TypeError): |
| 465 | """ |
| 466 | Exception that is raised when an &xist; constructor gets passed an unconvertable object. |
468 | 467 | """ |
469 | 468 | |
… |
… |
|
472 | 471 | |
473 | 472 | 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__) |
475 | 474 | |
476 | 475 | |
… |
… |
|
2661 | 2660 | loc = "" |
2662 | 2661 | 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() |
2666 | 2662 | |
2667 | 2663 | |
-
r2710
|
r2711
|
|
62 | 62 | node.append(html.p.Attrs.id(7)) |
63 | 63 | 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)) |
65 | 65 | |
66 | 66 | |