etree throws IOError when real error is file or directory not found
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
etree throws IOError when real error is file or directory not found
Because I have a bad directory name I get:
Traceback (most recent call last):
File "U:\Documents\
wsdl = etree.parse(
File "lxml.etree.pyx", line 3201, in lxml.etree.parse (src\lxml\
File "parser.pxi", line 1571, in lxml.etree.
File "parser.pxi", line 1600, in lxml.etree.
File "parser.pxi", line 1500, in lxml.etree.
File "parser.pxi", line 1047, in lxml.etree.
File "parser.pxi", line 577, in lxml.etree.
File "parser.pxi", line 676, in lxml.etree.
File "parser.pxi", line 614, in lxml.etree.
IOError: Error reading file 'U:\xDocuments\
Should throw more accurate error like: File or directory not found.
Python : sys.version_
lxml.etree : (3, 2, 3, 0)
libxml used : (2, 9, 1)
libxml compiled : (2, 9, 1)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)
I'm not sure it's worth special casing this specific error - we'd have to make sure the source is actually (and definitely) a reference to a local file, and then check if that exists and raise a different error if not. Might have side effects on other cases, e.g. relative URLs.
I guess I'd consider a patch if you wrote it, but please make sure you include tests that check different types of input URLs/file paths, that work on all operating systems and with Python 2.4 and later, including Python 3. Then open a pull request for it on github.