[Lxml-checkins] r43534 - lxml/trunk/src/lxml
scoder at codespeak.net
scoder at codespeak.net
Mon May 21 18:03:17 CEST 2007
Author: scoder
Date: Mon May 21 18:03:15 2007
New Revision: 43534
Modified:
lxml/trunk/src/lxml/objectify.pyx
Log:
raise ValueError instead of TypeError when XSD namespace is missing in objectify
Modified: lxml/trunk/src/lxml/objectify.pyx
==============================================================================
--- lxml/trunk/src/lxml/objectify.pyx (original)
+++ lxml/trunk/src/lxml/objectify.pyx Mon May 21 18:03:15 2007
@@ -1458,7 +1458,7 @@
# StrType does not have a typecheck but is the default anyway,
# so just accept it if given as type information
if pytype is None:
- return pytype
+ return None
value = textOf(c_node)
try:
pytype.type_check(value)
@@ -1468,7 +1468,6 @@
pass
return None
-
def annotate(element_or_tree, ignore_old=True):
"""Recursively annotates the elements of an XML tree with 'pytype'
attributes.
@@ -1503,8 +1502,8 @@
if dict_result is not NULL:
pytype = <PyType>dict_result
if pytype is not StrType:
- # StrType does not have a typecheck but is the default anyway,
- # so just accept it if given as type information
+ # StrType does not have a typecheck but is the default
+ # anyway, so just accept it if given as type information
pytype = _check_type(c_node, pytype)
if pytype is None:
@@ -1766,7 +1765,7 @@
prefix, name = _xsi.split(':', 1)
ns = nsmap.get(prefix)
if ns != XML_SCHEMA_NS:
- raise TypeError, "XSD types require the XSD namespace"
+ raise ValueError, "XSD types require the XSD namespace"
elif nsmap is _DEFAULT_NSMAP:
name = _xsi
_xsi = 'xsd:' + _xsi
@@ -1778,7 +1777,7 @@
_xsi = prefix + ':' + _xsi
break
else:
- raise TypeError, "XSD types require the XSD namespace"
+ raise ValueError, "XSD types require the XSD namespace"
python.PyDict_SetItem(_attributes, XML_SCHEMA_INSTANCE_TYPE_ATTR, _xsi)
if _pytype is None:
# allow using unregistered or even wrong xsi:type names
More information about the lxml-checkins
mailing list