New submission from Nikita Sobolev <m...@sobolevn.me>:
Right now this works: ``` >>> import textwrap >>> textwrap.TextWrapper.x ' ' >>> textwrap.TextWrapper.uspace 32 ``` This happens because of these lines: https://github.com/python/cpython/blame/606e496dd6e2ace298532da200169124c26ae0f2/Lib/textwrap.py#L66-L69 Notice that `uspace` and `x` are both undocumented, untested, and unused in our code. Similar variables in the same class body are then deleted from the scope: ``` wordsep_simple_re = re.compile(r'(%s+)' % whitespace) del whitespace ``` 1. https://github.com/python/cpython/blame/606e496dd6e2ace298532da200169124c26ae0f2/Lib/textwrap.py#L99 2. https://github.com/python/cpython/blame/606e496dd6e2ace298532da200169124c26ae0f2/Lib/textwrap.py#L106 I propose to add `del x, uspace` as well. These two probably should not be leaking and should not be exposed. ---------- components: Library (Lib) messages: 411850 nosy: sobolevn priority: normal severity: normal status: open title: `textwrap.TextWrapper` leaks two intermediate vars into class namespace type: behavior versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46545> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com