]> granicus.if.org Git - python/commitdiff
Simplify code in warnings modules (#1957)
authorAlex Gaynor <alex.gaynor@gmail.com>
Mon, 5 Jun 2017 13:13:50 +0000 (09:13 -0400)
committerGitHub <noreply@github.com>
Mon, 5 Jun 2017 13:13:50 +0000 (09:13 -0400)
Metaprogramming a list of attributes was excessive, and made the code less readable and slower.

Backport of 5de3a64179bafcd440b32849b1129ed1fea47b85

Lib/warnings.py

index 41f700b7a05c0b3fdebb4f2e787c7b36f52f222d..84f111d6c97fef6a49fea32a6343b8bd866f7669 100644 (file)
@@ -309,9 +309,12 @@ class WarningMessage(object):
 
     def __init__(self, message, category, filename, lineno, file=None,
                     line=None):
-        local_values = locals()
-        for attr in self._WARNING_DETAILS:
-            setattr(self, attr, local_values[attr])
+        self.message = message
+        self.category = category
+        self.filename = filename
+        self.lineno = lineno
+        self.file = file
+        self.line = line
         self._category_name = category.__name__ if category else None
 
     def __str__(self):