Skip to content

Fix single-element tuple typos in idlelib and test_email - #161423

Closed
PavlNekrasov wants to merge 1 commit into
python:mainfrom
PavlNekrasov:fix-single-element-tuple
Closed

PavlNekrasov wants to merge 1 commit into
python:mainfrom
PavlNekrasov:fix-single-element-tuple

Conversation

@PavlNekrasov

Copy link
Copy Markdown

1. Lib/idlelib/redirector.py — repr shows a spurious tuple

The comma inside the substitution field makes the expression a one-element
tuple, so repr() returns ('WidgetRedirector',)(Text<.text>) instead of
WidgetRedirector(Text<.text>). The same mistake is duplicated in
OriginalCommand.__repr__ in the same file.

def __repr__(self):
w = self.widget
return f"{self.__class__.__name__,}({w.__class__.__name__}<{w._w}>)"

def __repr__(self):
return f"{self.__class__.__name__,}({self.redir!r}, {self.operation!r})"

2. Lib/test/test_email/test_message.py — header never appended

if subtype != 'no_content':
('content-shadow', 'Logrus'),

The tuple is created and immediately discarded, so content-shadow never ends
up in msg_headers and the check that non-standard content-* headers (other
than Content-Type) are copied to the part in _check_make_multipart never
runs:

for name, value in msg_headers:
if name.lower().startswith('content-'):
self.assertEqual(part[name], value)
count += 1

The mistake masks a real regression: if the condition in Lib/email/message.py
is narrowed to Content-Type only, the current test set stays green (307 OK),
while with the content-shadow header properly appended 36 tests fail.

Found by Linux Verification Center (linuxtesting.org) with SVACE

Remove the stray comma in two __repr__ f-strings and append the
('content-shadow', 'Logrus') header instead of discarding it.
@bedevere-app

bedevere-app Bot commented Nov 5, 2026

Copy link
Copy Markdown

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.

@picnixz

picnixz commented Nov 5, 2026

Copy link
Copy Markdown
Member

Please create an issue.

@picnixz

picnixz commented Nov 5, 2026

Copy link
Copy Markdown
Member

These are also two unrelated changes so you need two distinct PR.

@picnixz picnixz closed this Nov 5, 2026
@terryjreedy

Copy link
Copy Markdown
Member

Yes, 2 PRs. I will handle the IDLE part and someone else the email issue.

@terryjreedy

Copy link
Copy Markdown
Member

@PavlNekrasov I figured out why the IDLE test passed without and with the error. The bad repr method does not affect the purpose of the class, but I will merge the proposed change when separately available.

This should actually be 2 issues. While it is true that the stray comma in the email test wraps the 2-tuple in a 1-tuple, the difference in the expression statement is not relevant as the result is not bound and disappears. The important proposed change is appending the 2-tuple to the message. If the test passes without (now) or with (proposed), then something seems amiss. At least in the test. An email person should decide.

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