Bug report #17106

PYthon Console Editor throws Exception when Pushing Save As button when Editor Window is still empty

Added by Richard Duivenvoorde over 2 years ago. Updated over 2 years ago.

Status:Closed
Priority:High
Assignee:-
Category:PyQGIS Console
Affected QGIS version:master Regression?:Yes
Operating System:Debian Testing Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:25005

Description

Seen in both 2.14 and master

Open Python Console (in Plugins menu)
Click 'Show Editor' button (little notepad icon)
In the editor widget, above the Untitled-0 tab there is a Save As button (floppy with pencil), which IS enabled, while the Save-button is NOT
Clicking that SaveAs button throws the following exception:

In Master

TypeError: join() argument must be str or bytes, not 'QDir' 
Traceback (most recent call last):
  File "/home/richard/bin/qgis_all/master/debug/share/qgis/python/console/console.py", line 633, in saveAsScriptFile
    pathFileName = os.path.join(folder, fileName)
  File "/usr/lib/python3.5/posixpath.py", line 89, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'QDir'

In 2.14

AttributeError: 'QDir' object has no attribute 'endswith' 
Traceback (most recent call last):
  File "/home/richard/bin/qgis_all/2.14/debug/share/qgis/python/console/console.py", line 668, in saveAsScriptFile
    pathFileName = os.path.join(folder, fileName)
  File "/usr/lib/python2.7/posixpath.py", line 70, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'QDir' object has no attribute 'endswith'

Python version: 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118] 
QGIS version: 2.14.16-Essen Essen, 7bc1bc4119 

In 2.14 it is NOT always, so it is apparently depending on some kind of 'starting' directory or so?
2.18 seems to work
Master always throws Exception with me here.

Associated revisions

Revision 999d93ad
Added by Alexander Bruy over 2 years ago

[console] return home directory as string instead of QDir instance (fix #17106)

History

#1 Updated by Richard Duivenvoorde over 2 years ago

  • Description updated (diff)

#2 Updated by Giovanni Manghi over 2 years ago

  • Regression? changed from No to Yes
  • Priority changed from Normal to High

#3 Updated by Alexander Bruy over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF