This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: `textwrap.TextWrapper` leaks two intermediate vars into class namespace
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: sobolevn
Priority: normal Keywords:

Created on 2022-01-27 10:26 by sobolevn, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg411850 - (view) Author: Nikita Sobolev (sobolevn) * (Python triager) Date: 2022-01-27 10:26
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.
msg411851 - (view) Author: Nikita Sobolev (sobolevn) * (Python triager) Date: 2022-01-27 10:27
Oups, somehow I created two identical issues. Closing this one.
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90703
2022-01-27 10:27:30sobolevnsetstatus: open -> closed
resolution: duplicate
messages: + msg411851

stage: resolved
2022-01-27 10:26:55sobolevncreate