Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork938
Closed
Labels
Description
# sscce.pyimportgitgit.Repo(".").tags[None]
$git initInitialized empty Git repository in /tmp/tmp.Xoz9gZndOi/.git/$venv/bin/python sscce.pyTraceback (most recent call last): File "sscce.py", line 5, in <module> git.Repo(".").tags[None] File "/tmp/tmp.Xoz9gZndOi/venv/lib/python3.8/site-packages/git/util.py", line 1087, in __getitem__ assert isinstance(index, (int, str, slice)), "Index of IterableList should be an int or str"AssertionError: Index of IterableList should be an int or str
Line 1087 inc84dde2
assertisinstance(index, (int,str,slice)),"Index of IterableList should be an int or str" |
assert
should not be used in product code because it can be ignored with-O
:$venv/bin/python -O sscce.pyTraceback (most recent call last): File "sscce.py", line 5, in <module> git.Repo(".").tags[None] File "/tmp/tmp.Xoz9gZndOi/venv/lib/python3.8/site-packages/git/util.py", line 1095, in __getitem__ return getattr(self, index)TypeError: getattr(): attribute name must be string
(In fact, that behavior is probablybetter since aTypeError
is more semantically meaningful.)
bandit
can catch this kind of thing:
$venv/bin/bandit venv/lib/python3.8/site-packages/git/util.py...>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Severity: Low Confidence: High CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html) Location: venv/lib/python3.8/site-packages/git/util.py:1087:8 More Info: https://bandit.readthedocs.io/en/1.7.4/plugins/b101_assert_used.html10861087 assert isinstance(index, (int, str, slice)), "Index of IterableList should be an int or str"10881089 if isinstance(index, int):...