Bug report #18617
QGIS3: SagaUtils.py fails when comman contains non-latin characters
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | Victor Olaya | ||
Category: | Processing/SAGA | ||
Affected QGIS version: | 3.1(master) | Regression?: | No |
Operating System: | MacOS | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 26505 |
Description
On MacOS running a Saga command where paths or filenames include non-latin characters fails with
"SagaUtils.py", line 116, in createSagaBatchJobFileFromSagaCommands UnicodeEncodeError: 'ascii' codec can't encode characters in position 218-228: ordinal not in range(128)
The complete stack trace below:
File "/Applications/QGIS3.app/Contents/MacOS/../Resources/python/plugins/processing/algs/saga/SagaUtils.py", line 113, in createSagaBatchJobFileFromSagaCommands fout.write('saga_cmd ' + command.encode('utf8') + '\n') TypeError: must be str, not bytes During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Applications/QGIS3.app/Contents/MacOS/../Resources/python/plugins/processing/algs/saga/SagaAlgorithm.py", line 320, in processAlgorithm SagaUtils.createSagaBatchJobFileFromSagaCommands(commands) File "/Applications/QGIS3.app/Contents/MacOS/../Resources/python/plugins/processing/algs/saga/SagaUtils.py", line 116, in createSagaBatchJobFileFromSagaCommands fout.write('saga_cmd ' + command + '\n') UnicodeEncodeError: 'ascii' codec can't encode characters in position 218-228: ordinal not in range(128)
The failing code was introduced in
https://github.com/qgis/QGIS/commit/f6710b0528af39f9df9ed9506e288ce9abb2d482#diff-1cfc1b0417f001d1bdb12afd71114978
I do not have a Mac to test but I am afraid binary mode for the sagaBatchJobFilename and Grass7BatchJobFilename would be necessary
to port this correctly to Python 3.
Related issues
Associated revisions
[processing] fixed handling of input filenames with non-ascii characters
Looks like there is no problem now in SAGA when using filenames with non-ascii chars, so some code used for replacing filenames has been removed. Also some code for python2, which is not needed now.
fixes #18617
History
#1 Updated by Jean Hemmi over 6 years ago
I have experienced the same issu on Windows with QGIS2 & this is alive with QGIS3.
I propose this bypass : call SAGA with temporary files (there is no non ascii there) and call a gdal transform with the right name (for instance temporary sdat is transfor in tiff).
Hope this'll help you
#2 Updated by Denis Rouzaud about 6 years ago
- Subject changed from QGIS3: SagaUtils.py fails on MacOS when comman contains non-latin characters to QGIS3: SagaUtils.py fails when comman contains non-latin characters
#3 Updated by Alexander Bruy almost 6 years ago
- Duplicated by Bug report #19351: [processing] Wrong management of locale in output result path added
#4 Updated by Victor Olaya over 5 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|fda41e3b0202041e681b2f69568f2a6dc2bb69e3.