* fix: informative type mismatch message
* don't match None types
This commit is contained in:
+3
-3
@@ -479,7 +479,6 @@ class autoxml(oo.autosuper):
|
|||||||
def encode(xml, node, value, errs):
|
def encode(xml, node, value, errs):
|
||||||
"""encode given value inside DOM node"""
|
"""encode given value inside DOM node"""
|
||||||
if value:
|
if value:
|
||||||
#FIXME: unicode() here?
|
|
||||||
writetext(xml, node, token, unicode(value))
|
writetext(xml, node, token, unicode(value))
|
||||||
else:
|
else:
|
||||||
if req == mandatory:
|
if req == mandatory:
|
||||||
@@ -487,8 +486,9 @@ class autoxml(oo.autosuper):
|
|||||||
|
|
||||||
def check(value, where):
|
def check(value, where):
|
||||||
errs = []
|
errs = []
|
||||||
if not isinstance(value, token_type):
|
if value and not isinstance(value, token_type):
|
||||||
errs.append(where + _('Type mismatch'))
|
errs.append(where + _('Type mismatch. Expected %s, got %s') %
|
||||||
|
(token_type, type(value)) )
|
||||||
return errs
|
return errs
|
||||||
|
|
||||||
def format(value, f, errs):
|
def format(value, f, errs):
|
||||||
|
|||||||
Reference in New Issue
Block a user