From: Alex Gaynor Date: Sun, 4 Jun 2017 15:34:16 +0000 (-0400) Subject: Simplify code in warnings modules (#1935) X-Git-Tag: v3.7.0a1~693 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5de3a64179bafcd440b32849b1129ed1fea47b85;p=thirdparty%2FPython%2Fcpython.git Simplify code in warnings modules (#1935) Metaprogramming a list of attributes was excessive, and made the code less readable and slower. --- diff --git a/Lib/warnings.py b/Lib/warnings.py index d7d88d3e3882..a1f774637a24 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -397,9 +397,13 @@ class WarningMessage(object): def __init__(self, message, category, filename, lineno, file=None, line=None, source=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.source = source self._category_name = category.__name__ if category else None def __str__(self):