Simplify code in warnings modules (#1935)

Metaprogramming a list of attributes was excessive, and made the code less readable and slower.
This commit is contained in:
Alex Gaynor 2017-06-04 11:34:16 -04:00 committed by Donald Stufft
parent 9f396b605e
commit 5de3a64179
1 changed files with 7 additions and 3 deletions

View File

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