[Expat-discuss] File not found error in the parser

Justin Seyster jseyster at cs.stonybrook.edu
Thu Jun 17 23:12:28 CEST 2010


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




More information about the Expat-discuss mailing list