Skip to content

gh-161295: Add a __repr__ to reprlib.Repr - #161296

Open
ZeroIntensity wants to merge 2 commits into
python:mainfrom
ZeroIntensity:reprlib/repr-repr
Open

ZeroIntensity wants to merge 2 commits into
python:mainfrom
ZeroIntensity:reprlib/repr-repr

Conversation

@ZeroIntensity

@ZeroIntensity ZeroIntensity commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

@bedevere-app bedevere-app Bot added awaiting core review type-feature A feature request or enhancement labels Nov 4, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35631233 | 📁 Comparing 1982ce6 against main (6d69297)

  🔍 Preview build  

2 files changed
± library/reprlib.html
± whatsnew/changelog.html

Comment thread Lib/reprlib.py
self.fillvalue = fillvalue
self.indent = indent

def __repr__(self):

@aisk aisk Nov 4, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
def __repr__(self):
@recursive_repr()
def __repr__(self):

Although a basic Repr doesn't have a self reference, someone may subclass it or add a self reference to an instance, which could cause infinite recursion. So it's better to use this to prevent it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants