Empty list is returned on DTD attributes

Bug #1266171 reported by Sworddragon on 2014-01-05
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

The following code returns an empty attribute list on the DTD element test but it has an attribute in the xml document:

#!/usr/bin/python3 -BEOObbs
# coding=utf-8

import io, lxml.etree

xml = lxml.etree.parse(io.BytesIO(b'''<?xml
<!DOCTYPE root [
 <!ATTLIST test
  attr (A | B | C) 'B'
 <!ELEMENT test (#PCDATA)>
 <!ELEMENT root (test)*>
element = xml.docinfo.internalDTD.elements()[0]

This is the output:

sworddragon@ubuntu:~/tmp$ ./test.py

Used versions:

Python : sys.version_info(major=3, minor=3, micro=3, releaselevel='final', serial=0)
lxml.etree : (3, 3, 0, -98)
libxml used : (2, 9, 1)
libxml compiled : (2, 9, 1)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)

scoder (scoder) wrote :

Thanks for the report and the test code. I can confirm this, and it applies only to internal/external subsets, not DTDs parsed independently. Working on a fix.

Changed in lxml:
assignee: nobody → scoder (scoder)
importance: Undecided → Medium
status: New → Confirmed
scoder (scoder) wrote :
Changed in lxml:
status: Confirmed → Fix Committed
scoder (scoder) wrote :

This is better as it additionally avoids keeping the document itself alive:


scoder (scoder) wrote :

Fixed in lxml 3.3.0.

Changed in lxml:
milestone: none → 3.3
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers