Python lxml.etree.relaxng返回DocumentInvalid而不记录错误的原因可能是什么?

Python lxml.etree.relaxng返回DocumentInvalid而不记录错误的原因可能是什么?,python,lxml,Python,Lxml,我的代码如下: try: schema = lxml.etree.RelaxNG(file=schema_file) schema.assertValid(etree) except lxml.etree.DocumentInvalid as exception: print(schema.error_log) print(exception.error_log) raise exception 它始终会引发DocumentInvalid错误: Docu

我的代码如下:

try:
    schema = lxml.etree.RelaxNG(file=schema_file)
    schema.assertValid(etree)
except lxml.etree.DocumentInvalid as exception:
    print(schema.error_log)
    print(exception.error_log)
    raise exception
它始终会引发DocumentInvalid错误:

DocumentInvalid: Document does not comply with schema
但是在模式错误日志或全局错误日志中都不会打印错误

这只会发生在某些文件中,其他文件会正确验证,或者给出无法验证的原因。(这是一个很长的模式,所以我不在这里引用。)


我甚至不知道从哪里开始找。原因可能是什么?

这就是获取错误消息的方式

try:
    schema = lxml.etree.RelaxNG(file=schema_file)
    schema.assertValid(etree)
except lxml.etree.DocumentInvalid as exception:
    print(exception.error_log.filter_from_errors()[0])
    raise exception

这就是获取错误消息的方式

try:
    schema = lxml.etree.RelaxNG(file=schema_file)
    schema.assertValid(etree)
except lxml.etree.DocumentInvalid as exception:
    print(exception.error_log.filter_from_errors()[0])
    raise exception