Bug report #13059

Indents in scratch.py written by 2.10 causes IndentationError in 2.8.2-LTR

Added by Kristian Evers about 5 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Expressions
Affected QGIS version:master Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:21129

Description

This bug presents it self when running two version of QGIS, 2.10.0 and 2.8.2-ltr, on the same computer with the same user.

The problem is that QGIS 2.10 automatically writes a poorly formatted scratch.py in .qgis2/plugins/expressions/. The generated file results in an IndentationError when QGIS 2.8.2-ltr is opened. The IndentationError occurs because all lines (except the first) in the file are indented for spaces. This obviously doesn't play nicely with the python interpreter. The exception is not seen in 2.10 because exceptions caused by bad user-code are not raised.

The problem arises in python/user.py because of a indented doc-string. I have attached a copy of a user.py that outputs a file that is formatted properly.

user.py Magnifier (2.25 KB) Kristian Evers, 2015-07-01 06:16 AM

user.patch Magnifier - QGIS/python/user.py (1.05 KB) Kristian Evers, 2015-07-03 02:25 AM

Associated revisions

Revision fbad6807
Added by Nathan Woodrow about 5 years ago

Fix #13059 - Fix expression template load error

Revision 7b15f7ac
Added by Nathan Woodrow about 5 years ago

Fix #13059 - Fix expression template load error

- Backported to 2.10.1
- Cherry-picked from fbad68075b71e2

History

#1 Updated by Kristian Evers about 5 years ago

Steps to reproduce:

1. Open QGIS 2.10
2. Add a layer.
3. Go to the Field Calculator (this will prompt QGIS to write a new 'scratch.py' file if it is not already there)
4. Close QGIS 2.10
5. Open QGIS 2.8.2-ltr
6. Python Error will show up before the main window. A IndentationError is reported.

See the attached pathc file.

#2 Updated by Nathan Woodrow about 5 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF