Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b9067d9

Browse files
rldhontnyalldawson
authored andcommittedMay 20, 2021
[Processing] Fix specific exception type in getParameterFromString
1 parent ef05b76 commit b9067d9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎python/plugins/processing/core/parameters.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def getParameterFromString(s, context=''):
116116
if len(params) > 2:
117117
try:
118118
params[2] = [int(p) for p in params[2].split(';')]
119-
except:
119+
except ValueError:
120120
params[2] = [getattr(QgsProcessing, p.split(".")[1]) for p in params[2].split(';')]
121121
if len(params) > 4:
122122
params[4] = True if params[4].lower() == 'true' else False
@@ -125,7 +125,7 @@ def getParameterFromString(s, context=''):
125125
params[3] = True if params[3].lower() == 'true' else False
126126
try:
127127
params[4] = [int(p) for p in params[4].split(';')]
128-
except:
128+
except ValueError:
129129
params[4] = [getattr(QgsProcessing, p.split(".")[1]) for p in params[4].split(';')]
130130
elif clazz == QgsProcessingParameterBoolean:
131131
if len(params) > 2:
@@ -141,7 +141,7 @@ def getParameterFromString(s, context=''):
141141
if len(params) > 4:
142142
try:
143143
params[4] = [int(p) for p in params[4].split(';')]
144-
except:
144+
except ValueError:
145145
params[4] = [getattr(QgsWkbTypes, p.split(".")[1]) for p in params[4].split(';')]
146146
if len(params) > 5:
147147
params[5] = True if params[5].lower() == 'true' else False
@@ -152,7 +152,7 @@ def getParameterFromString(s, context=''):
152152
if len(params) > 2:
153153
try:
154154
params[2] = int(params[2])
155-
except:
155+
except ValueError:
156156
params[2] = getattr(QgsProcessingParameterNumber, params[2].split(".")[1])
157157
if len(params) > 4:
158158
params[4] = True if params[4].lower() == 'true' else False
@@ -179,15 +179,15 @@ def getParameterFromString(s, context=''):
179179
if len(params) > 2:
180180
try:
181181
params[2] = [int(p) for p in params[2].split(';')]
182-
except:
182+
except ValueError:
183183
params[2] = [getattr(QgsProcessing, p.split(".")[1]) for p in params[2].split(';')]
184184
if len(params) > 4:
185185
params[4] = True if params[4].lower() == 'true' else False
186186
elif clazz == QgsProcessingParameterMultipleLayers:
187187
if len(params) > 2:
188188
try:
189189
params[2] = int(params[2])
190-
except:
190+
except ValueError:
191191
params[2] = getattr(QgsProcessing, params[2].split(".")[1])
192192
if len(params) > 4:
193193
params[4] = True if params[4].lower() == 'true' else False
@@ -204,7 +204,7 @@ def getParameterFromString(s, context=''):
204204
if len(params) > 4:
205205
try:
206206
params[4] = int(params[4])
207-
except:
207+
except ValueError:
208208
params[4] = getattr(QgsProcessingParameterField, params[4].split(".")[1])
209209
if len(params) > 5:
210210
params[5] = True if params[5].lower() == 'true' else False
@@ -216,15 +216,15 @@ def getParameterFromString(s, context=''):
216216
if len(params) > 2:
217217
try:
218218
params[2] = int(params[2])
219-
except:
219+
except ValueError:
220220
params[2] = getattr(QgsProcessingParameterFile, params[2].split(".")[1])
221221
if len(params) > 5:
222222
params[5] = True if params[5].lower() == 'true' else False
223223
elif clazz == QgsProcessingParameterNumber:
224224
if len(params) > 2:
225225
try:
226226
params[2] = int(params[2])
227-
except:
227+
except ValueError:
228228
params[2] = getattr(QgsProcessingParameterNumber, params[2].split(".")[1])
229229
if len(params) > 3:
230230
params[3] = float(params[3].strip()) if params[3] is not None else None
@@ -263,7 +263,7 @@ def getParameterFromString(s, context=''):
263263
if len(params) > 2:
264264
try:
265265
params[2] = int(params[2])
266-
except:
266+
except ValueError:
267267
params[2] = getattr(QgsProcessing, params[2].split(".")[1])
268268
if len(params) > 4:
269269
params[4] = True if params[4].lower() == 'true' else False

0 commit comments

Comments
 (0)
Please sign in to comment.