LXML should respect case of infinity and NaN for XML Schema conformance
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Committed
|
Low
|
scoder |
Bug Description
lxml.objectify XSI-annotates Python float as xsd:double. W3Cs XML Schema Datatype specification for double [0] says:
> The special values positive and negative infinity and not-a-number have lexical representations INF, -INF and NaN, respectively.
Thus case matters
- "INF","-INF", "NaN" are valid
- but lxml.objectify generates "inf", "-inf", "nan", which are invalid
Reproducer:
from lxml import etree, objectify
root = objectify.
objectify.
print(etree.
gives
<test xmlns:xsd="http://
xmllint (as well as multiple other schema validators I've tested) will correctly detect the error:
Schemas validity error : Element 'test': 'inf' is not a valid value of the atomic type 'xs:double'.
[0] https:/
lxml.etree : (4, 7, 1, 0)
libxml used : (2, 9, 4)
libxml compiled : (2, 9, 4)
libxslt used : (1, 1, 33)
libxslt compiled : (1, 1, 33)
Changed in lxml: | |
milestone: | 4.9.0 → 4.8.0 |
Fixed in https:/ /github. com/lxml/ lxml/pull/ 338