Improve exception message

Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Rémi Lapeyre 2020-04-08 15:26:57 +02:00 committed by GitHub
parent 22e475cd6d
commit f42eea5db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -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