bpo-46544: Do not leak x and uspace in textwrap.TextWrapper (GH-30955)

This commit is contained in:
Nikita Sobolev 2022-01-27 14:55:58 +03:00 committed by GitHub
parent 08c0ed2d9c
commit 82bce54614
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -63,10 +63,7 @@ class TextWrapper:
Append to the last line of truncated text.
"""
unicode_whitespace_trans = {}
uspace = ord(' ')
for x in _whitespace:
unicode_whitespace_trans[ord(x)] = uspace
unicode_whitespace_trans = dict.fromkeys(map(ord, _whitespace), ord(' '))
# This funky little regex is just the trick for splitting
# text up into word-wrappable chunks. E.g.

View file

@ -0,0 +1,2 @@
Don't leak ``x`` & ``uspace`` intermediate vars in
:class:`textwrap.TextWrapper`.