File not found error in the parser
Justin Seyster <[email protected]> Thu, 17 Jun 2010 17:12:28 -0400
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <1276809148.32549.19.camel@crossroads> |
I'm running into a really weird issue parsing a document with Expat: I
keep getting file not found errors on files that exist.
The weirdest part is that if I parse files from one particular
directory, it works without a problem. Any other directory, however,
and I get an IOError exception. (All the directories and files I've
tried have standard Unix permissions, and I am their owner.) My code
looks like this:
# I verified that this does indeed return an Expat parser.
parser = make_parser()
parser.setFeature(feature_namespaces, 0)
dh = BlankHandler()
parser.setContentHandler(dh)
try:
xmlhandle = open(filename, 'r')
# Attempting a read here succeeds
parser.parse(xmlhandle) # This line throws the IOError
xmlhandle.close()
except IOError as e:
print e.strerror
sys.exit(1)
Running this on files in most directories gives me the error:
"No such file or directory"
I know the file exists, however, because attempts to read it after
opening it but before parsing it succeed. I also know that my code is
at least semi-valid because it correctly parses files placed in one
particular directory.
Has anybody heard of this kind of problem before? Thanks.
--Justin