Hello,
I don't want to report a bug (yet), as I don't know as what this should be
reported - but it's definitely a problem.
My info on the system where I reproduced it:
Python : sys.version_info(major=3, minor=4, micro=3,
releaselevel='final', serial=0)
lxml.etree : (3, 5, 0, 0)
libxml used : (2, 9, 1)
libxml compiled : (2, 9, 1)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)
In lxml==3.2.1 under Python 2.7 I instantiated it succesfully like this
XmlParser([...], XMLSchema_schema=None, [...]) (note the underscore)
In lxml==3.5.0 under Python 3.4 this started failing with the error:
Traceback (most recent call last):
File "/path/to/my/script.py", line 7, in <module>
XMLSchema_schema=xmlSchema)
File "src/lxml/parser.pxi", line 1437, in lxml.etree.XMLParser.__init__
(src/lxml/lxml.etree.c:120522)
TypeError: __init__() got an unexpected keyword argument 'XMLSchema_schema'
from lxml import etree
The code looks like this:
from lxml import etree
xmlSchema = etree.XMLSchema(file='/path/to/some/schema.xsd')
parser = etree.XMLParser(
remove_blank_text=True, attribute_defaults=True,
XMLSchema_schema=xmlSchema)
It can be fixed by just using "schema" instead of "XMLSchema_schema" as
keyword argument:
XmlParser([...], schema=xmlSchema, [...])
---
I had a look at the sources of both versions.
The affected source line In file src/lxml/lxml.etree.pyx:1437 in both
versions looks the same
def __init__([...], XMLSchema schema=None, [...]):
so I guess somewhere between 3.21. and 3.5.0 the type hint does not get
baked into the keyword argument anymore? My question would be: Is this a
bug in the documentation that fails to identify the new keyword parameter
as "schema" or is this an unwanted change of the parameter that should
actually remain as "XMLSchema_schema" and turned accidentally into "schema"?
cheers
Oliver