From f42eea5db20d6ce4da807fd19a3b7ac4513adc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lapeyre?= Date: Wed, 8 Apr 2020 15:26:57 +0200 Subject: [PATCH] Improve exception message Co-Authored-By: Serhiy Storchaka --- Lib/warnings.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/warnings.py b/Lib/warnings.py index 99037fc967b..0487342a913 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -147,10 +147,8 @@ def filterwarnings(action, message="", category=Warning, module="", lineno=0, raise TypeError("category must be a Warning subclass") if not isinstance(module, str): raise TypeError("module must be a string") - if not isinstance(lineno, int): - raise TypeError("lineno must be an int") - if lineno < 0: - raise ValueError("lineno must be an int >= 0") + if not isinstance(lineno, int) or lineno < 0: + raise ValueError("lineno must be a non-negative integer") if message or module: import re