Skip to content

Commit a00adc3

Browse files
committed
Catch specific exceptions
1 parent 86fce61 commit a00adc3

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

dpath/segments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def set(
326326
# Unfortunately, for our use, 'x in thing' for lists checks
327327
# values, not keys whereas dicts check keys.
328328
current[segment]
329-
except:
329+
except (KeyError, IndexError):
330330
if creator is not None:
331331
creator(current, segments, i, hints)
332332
else:

dpath/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _split_path(path: str, separator: str) -> Union[List[PathSegment], PathSegme
2929
for segment in split_segments:
3030
try:
3131
final.append(int(segment))
32-
except:
32+
except ValueError:
3333
final.append(segment)
3434
split_segments = final
3535

@@ -325,9 +325,9 @@ def merger(dst, src, _segments=()):
325325
except TypeError:
326326
segments.set(dst, current_path, found)
327327
continue
328-
except:
328+
except Exception:
329329
raise
330-
except:
330+
except Exception:
331331
# We have a dictionary like thing and we need to attempt to
332332
# recursively merge it.
333333
merger(dst, found, current_path)

0 commit comments

Comments
 (0)