diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | pylint/checkers/strings.py | 2 | ||||
-rw-r--r-- | pylint/test/functional/suspicious_str_strip_call.py | 1 |
3 files changed, 5 insertions, 1 deletions
@@ -7,6 +7,9 @@ What's New in Pylint 2.3.0? Release date: TBA +* Fixed a crash that occurred for ``bad-str-strip-call`` when ``strip()`` received ``None`` + + Close #2743 * Don't emit ``*-not-iterating`` checks for builtins consumed by ``itertools`` diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py index 8d1a101e7..dd2904301 100644 --- a/pylint/checkers/strings.py +++ b/pylint/checkers/strings.py @@ -345,7 +345,7 @@ class StringFormatChecker(BaseChecker): ): if func.name in ("strip", "lstrip", "rstrip") and node.args: arg = utils.safe_infer(node.args[0]) - if not isinstance(arg, astroid.Const): + if not isinstance(arg, astroid.Const) or not isinstance(arg.value, str): return if len(arg.value) != len(set(arg.value)): self.add_message( diff --git a/pylint/test/functional/suspicious_str_strip_call.py b/pylint/test/functional/suspicious_str_strip_call.py index e859f25f8..bc3a27c27 100644 --- a/pylint/test/functional/suspicious_str_strip_call.py +++ b/pylint/test/functional/suspicious_str_strip_call.py @@ -7,3 +7,4 @@ __revision__ = 1 u''.strip('http://') # [bad-str-strip-call] u''.lstrip('http://') # [bad-str-strip-call] b''.rstrip('http://') # [bad-str-strip-call] +"some_sensible_string".strip(None) # Don't crash |