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

ResourceWarning: unclosed file <_io.BufferedRandom name='path/to/tmp_mxwkwqh.sqlite'> #196

Open
5j9 opened this issue Sep 29, 2023 · 0 comments · May be fixed by #197
Open

ResourceWarning: unclosed file <_io.BufferedRandom name='path/to/tmp_mxwkwqh.sqlite'> #196

5j9 opened this issue Sep 29, 2023 · 0 comments · May be fixed by #197

Comments

@5j9
Copy link

5j9 commented Sep 29, 2023

Consider the following script:

# script.py
import browser_cookie3
browser_cookie3.firefox()

Run it with with -Wa flag so resource warnings are shown. (python -Wa 'path/to/script.py')
The following warning is shown:

$ python -Wa 'script.py'
C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py:373: ResourceWarning: unclosed file <_io.BufferedRandom name='C:\\Users\\a\\AppData\\Local\\Temp\\
tmp3g0or7p1.sqlite'>
  suffix='.sqlite').name
ResourceWarning: Enable tracemalloc to get the object allocation traceback

The result after enabling tracemalloc:

$ python -Wa -X tracemalloc 'script.py'
C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py:373: ResourceWarning: unclosed file <_io.BufferedRandom name='C:\\Users\\a\\AppData\\Local\\Temp\\
tmp1tq62xnu.sqlite'>
  suffix='.sqlite').name
Object allocated at (most recent call last):
  File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\tempfile.py", lineno 563
    file = _io.open(dir, mode, buffering=buffering,
5j9 added a commit to 5j9/browser_cookie3 that referenced this issue Oct 2, 2023
The context manager will close the file explicitly.

closes borisbabic#196
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

Successfully merging a pull request may close this issue.

1 participant