Skip to content

gh-150427: Remove unused __linecnt attribute from _sitebuiltins#150428

Merged
picnixz merged 1 commit into
python:mainfrom
angelolicastro:gh-150427_remove_unused_attribute
May 25, 2026
Merged

gh-150427: Remove unused __linecnt attribute from _sitebuiltins#150428
picnixz merged 1 commit into
python:mainfrom
angelolicastro:gh-150427_remove_unused_attribute

Conversation

@angelolicastro
Copy link
Copy Markdown
Contributor

@angelolicastro angelolicastro commented May 25, 2026

_sitebuiltins._Printer.__setup creates an instance attribute, __linecnt, which is unused:

cpython % git grep __linecnt
Lib/_sitebuiltins.py:        self.__linecnt = len(self.__lines)

This could be used by _sitebuiltins._Printer.__repr__ in lieu of len(self.__lines):

        self.__setup()
        if len(self.__lines) <= self.MAXLINES:
            return "\n".join(self.__lines)

But because len(self.__lines) is only referenced as such, we can remove __linecnt instead.

This was introduced in d125239 but also unused then.

There is no behavior change, and all tests pass.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 25, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 25, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@picnixz

This comment was marked as resolved.

Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

It's a good thing to remove an unused attribute. If we don't remove it, someone else will come in a few months with the same issue :-)

Copy link
Copy Markdown
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

If this can save us from having future PRs wanting to make that edit, I'm ok with it.

@picnixz picnixz merged commit c549837 into python:main May 25, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants