Skip to content

Commit 82bce54

Browse files
authored
bpo-46544: Do not leak x and uspace in textwrap.TextWrapper (GH-30955)
1 parent 08c0ed2 commit 82bce54

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Lib/textwrap.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ class TextWrapper:
6363
Append to the last line of truncated text.
6464
"""
6565

66-
unicode_whitespace_trans = {}
67-
uspace = ord(' ')
68-
for x in _whitespace:
69-
unicode_whitespace_trans[ord(x)] = uspace
66+
unicode_whitespace_trans = dict.fromkeys(map(ord, _whitespace), ord(' '))
7067

7168
# This funky little regex is just the trick for splitting
7269
# text up into word-wrappable chunks. E.g.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Don't leak ``x`` & ``uspace`` intermediate vars in
2+
:class:`textwrap.TextWrapper`.

0 commit comments

Comments
 (0)