From: Alex Gaynor Date: Mon, 5 Jun 2017 13:13:50 +0000 (-0400) Subject: Simplify code in warnings modules (#1957) X-Git-Tag: v2.7.14rc1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e14af32cc656249c2d785d190cc981869aa257f6;p=thirdparty%2FPython%2Fcpython.git Simplify code in warnings modules (#1957) Metaprogramming a list of attributes was excessive, and made the code less readable and slower. Backport of 5de3a64179bafcd440b32849b1129ed1fea47b85 --- diff --git a/Lib/warnings.py b/Lib/warnings.py index 41f700b7a05c..84f111d6c97f 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -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):