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.

Title: `pydoc.Helper` leaks several `for` loop variables
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: sobolevn
Priority: normal Keywords: patch

Created on 2022-01-27 11:40 by sobolevn, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 30957 open sobolevn, 2022-01-27 11:43
Messages (1)
msg411856 - (view) Author: Nikita Sobolev (sobolevn) * (Python triager) Date: 2022-01-27 11:40
Here's the problem. `pydoc.Helper` is defined as:

class Helper:
    for topic, symbols_ in _symbols_inverse.items():
        for symbol in symbols_:
            topics = symbols.get(symbol, topic)
            if topic not in topics:
                topics = topics + ' ' + topic
            symbols[symbol] = topics


It causes some unwanted consequences: `topic, symbols_, symbol` are leaking to the class's namespace. Example:

>>> import pydoc
>>> pydoc.Helper.symbol
>>> pydoc.Helper.topic
>>> pydoc.Helper.symbols_
('j', 'J')

There's also `topics` var, but it is shadowed later.

So, I propose deleting all intermediate variables right after the `for` loop.
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90705
2022-01-27 11:43:23sobolevnsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29136
2022-01-27 11:40:53sobolevncreate