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

Python console editor warning: "ResourceWarning: unclosed file" #57071

Closed
2 tasks done
agiudiceandrea opened this issue Apr 6, 2024 · 1 comment
Closed
2 tasks done
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Python Console Python Console Regression Something which used to work, but doesn't anymore

Comments

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Apr 6, 2024

What is the bug or the crash?

Using QGIS 3.34.5 or QGIS 3.36.1 on Windows, when an unsaved Python script in the Python console editor is executed, the following warning is displayed in the Log Messages panel:

WARNING    warning:C:\OS4406~1/apps/qgis-ltr/./python\console\console_editor.py:303: ResourceWarning: unclosed file 
              name = tempfile.NamedTemporaryFile(delete=False).name
             
             traceback: File "C:\OS4406~1/apps/qgis-ltr/./python\console\console.py", line 660, in runScriptEditor
              self.tabEditorWidget.currentWidget().runScriptCode()
              File "C:\OS4406~1/apps/qgis-ltr/./python\console\console_editor.py", line 326, in runScriptCode
              filename = self.createTempFile()
              File "C:\OS4406~1/apps/qgis-ltr/./python\console\console_editor.py", line 303, in createTempFile
              name = tempfile.NamedTemporaryFile(delete=False).name

Steps to reproduce the issue

  1. Open the Python console editor
  2. type: print('test')
  3. click the "Run Script" button

Versions

QGIS version
3.34.5-Prizren
QGIS code revision
4b30849
Qt version
5.15.3
Python version
3.9.18
GDAL/OGR version
3.8.4
PROJ version
9.3.1
EPSG Registry database version
v10.098 (2023-11-24)
GEOS version
3.12.1-CAPI-1.18.1
SQLite version
3.41.1
PDAL version
2.6.0
PostgreSQL client version
16.2
SpatiaLite version
5.1.0
QWT version
6.1.6
QScintilla2 version
2.13.4
OS version
Windows 10 Version 1903

Active Python plugins
qgis2web
3.19.0
db_manager
0.1.20
grassprovider
2.12.99
MetaSearch
0.3.6
processing
2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

The warning was not displayed using QGIS 3.28.15.
It seems the warning is displayed since QGIS 3.30.

@agiudiceandrea agiudiceandrea added Bug Either a bug report, or a bug fix. Let's hope for the latter! Regression Something which used to work, but doesn't anymore Python Console Python Console labels Apr 6, 2024
@nyalldawson
Copy link
Collaborator

Not an issue in 3.38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Python Console Python Console Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

No branches or pull requests

2 participants