Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file is not closed #88

Open
fatihsirin opened this issue Jul 8, 2023 · 1 comment
Open

file is not closed #88

fatihsirin opened this issue Jul 8, 2023 · 1 comment

Comments

@fatihsirin
Copy link

fatihsirin commented Jul 8, 2023

hachoir/parser/guess.py

def createParser(filename, real_filename=None, tags=None):
    """
    Create a parser from a file or returns None on error.

    Options:
    - file (str|io.IOBase): Input file name or
        a byte io.IOBase stream  ;
    - real_filename (str): Real file name.
    """
    if not tags:
        tags = []
    stream = FileInputStream(filename, real_filename, tags=tags)
    guess = guessParser(stream)
    if guess is None:
        stream.close()
    return guess
You should return stream with guess. You should let us close stream.
@oliver
Copy link
Contributor

oliver commented Jan 6, 2025

It looks like you can still get the stream from the returned parser object, no? Also, if you call parser.close() the stream will be closed. Is there any other case that is not covered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants