Skip to content

Fix leading-zero trimming in IntEdit with a bytes caption - #1525

Merged
penguinolog merged 1 commit into
urwid:masterfrom
charan-rathore:fix/intedit-bytes-leading-zeros
Oct 28, 2026
Merged

penguinolog merged 1 commit into
urwid:masterfrom
charan-rathore:fix/intedit-bytes-leading-zeros

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor
Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)
Description

IntEdit accepts bytes captions, but its zero-trimming helper compares a bytes slice with the string '0'. Typing 7 into an initial zero therefore leaves b'07' instead of b'7'. Moving the cursor past leading zeros has the same problem.

Choose the zero literal to match the text type. This keeps the string behavior and makes bytes text follow the same trimming rules. Tests cover typing, direct insertion, deletion, moving to the end, preserving a lone zero, cursor position, numeric value and postchange counts for string and bytes captions.

On master 3c3fa74, Linux and Python 3.12.15:

  • Unchanged source: five bytes-case failures, with four passing controls.
  • Patched edit/numedit tests: 119 passed, 215 subtests passed.
  • Full suite: 2,493 passed, 34 skipped, 5,243 subtests passed.
  • Ruff, formatting and mypy pass (95 source files).

A separate macOS Python 3.12 run had 2,494 passed, 12 failed and 33 skipped. The same 12 Text rendering subcases fail on unchanged source. Its mypy runs report the same eight curses errors before and after the fix. Full tox, other Python versions, pylint and Pyrefly were not run locally.

@penguinolog
penguinolog merged commit f4ba6a6 into urwid:master Oct 28, 2026
31 checks passed
@penguinolog penguinolog added bug Maintenance Project maintenance related and removed bug labels Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance Project maintenance related Tests Tests Widget

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants