⚡ Sangsakala Proxy 🏠 Home
Skip to content

gh-161289: Respect fillvalue length when truncating in reprlib.Repr - #161290

Open
andresdelfino wants to merge 1 commit into
python:mainfrom
andresdelfino:reprlib-fillvalue-length
Open

andresdelfino wants to merge 1 commit into
python:mainfrom
andresdelfino:reprlib-fillvalue-length

Conversation

@andresdelfino

@andresdelfino andresdelfino commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Repr.repr_str(), Repr.repr_int() and Repr.repr_instance() assumed the fill value is three characters long (the default '...') when deciding how many characters to keep around it. With a custom Repr.fillvalue of another length, the truncated result exceeded or fell short of maxstring, maxlong and maxother. This uses len(self.fillvalue) instead. Output with the default fill value is unchanged.

The new test checks the exact truncated output of a string, an int and an object for a 1-character and a 6-character fill value; it fails without the fix.

🤖 Generated with Claude Code

…Repr

repr_str(), repr_int() and repr_instance() computed how many characters
to keep around the fill value assuming it is always three characters
long (the default '...'). With a custom Repr.fillvalue of another
length, the result exceeded or fell short of maxstring, maxlong and
maxother. Use len(self.fillvalue) instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant