etree.RelaxNG fails to load RELAX NG compact (.rnc) file

Bug #1827833 reported by Yang Yang on 2019-05-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Medium
Unassigned

Bug Description

With rnc2rng 2.6.1 installed, etree.RelaxNG still fails to load a .rnc file.

test.rnc:

start = element a {empty}

test.py:

from lxml import etree
etree.RelaxNG(file='test.rnc') # ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

It seems that the rng content generated by rnc2rng is rejected by etree.RelaxNG because it begins with '<?xml version="1.0" encoding="UTF-8"?>'.

Version info:

Python : sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
lxml.etree : (4, 3, 3, 0)
libxml used : (2, 9, 5)
libxml compiled : (2, 9, 5)
libxslt used : (1, 1, 30)
libxslt compiled : (1, 1, 30)

scoder (scoder) wrote :

Thanks for the report.
Fixed here: https://github.com/lxml/lxml/commit/bb2a4fd588d1cdf5ecd9badd618505d578ea2942

As the saying goes, it's either tested or broken. The integration tests with rnc2rng were not automatically running in CI. They are now.

Changed in lxml:
assignee: nobody → scoder (scoder)
importance: Undecided → Medium
milestone: none → 4.4.0
status: New → Fix Committed
scoder (scoder) on 2019-08-11
Changed in lxml:
assignee: scoder (scoder) → nobody
milestone: 4.4.0 → none
status: Fix Committed → Fix Released
milestone: none → 4.4.0
Yang Yang (wdscxsj) on 2019-08-11
Changed in lxml:
status: Fix Released → Confirmed
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers