Skip to content

bpo-46544: do not leak x and uspace in textwrap #30955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 27, 2022

@sobolevn sobolevn changed the title bpo-46565: do not leak x and uspace in textwrap bpo-46564: do not leak x and uspace in textwrap Jan 27, 2022
@sobolevn sobolevn changed the title bpo-46564: do not leak x and uspace in textwrap bpo-46544: do not leak x and uspace in textwrap Jan 27, 2022
Lib/textwrap.py Outdated
@@ -67,6 +67,7 @@ class TextWrapper:
uspace = ord(' ')
for x in _whitespace:
unicode_whitespace_trans[ord(x)] = uspace
del x, uspace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to replace it with

unicode_whitespace_trans = {ord(x): b' '[0] for x in _whitespace}

or

unicode_whitespace_trans = dict.fromkeys(map(ord, _whitespace), ord(' '))

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A news entry for such internal changes seems to have low value for end users!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useful in the unlikely case someone is relying on these attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants