Skip to content

Fix console.print() with empty args to respect end parameter#3962

Closed
veeceey wants to merge 1 commit intoTextualize:masterfrom
veeceey:fix/issue-3701-print-empty-end
Closed

Fix console.print() with empty args to respect end parameter#3962
veeceey wants to merge 1 commit intoTextualize:masterfrom
veeceey:fix/issue-3701-print-empty-end

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 8, 2026

Summary

Fixes #3701

When console.print() was called with no arguments but a custom end parameter, it would print a newline instead of the end character. This was because empty objects were always replaced with NewLine() regardless of the end parameter.

Changes

  • Modified Console.print() in rich/console.py to only use NewLine() when end is the default "\n"
  • When end is a custom value, use an empty Text object that will properly render with the custom end character
  • Added test test_print_empty_with_end() to verify the fix

Test plan

  • Added regression test that verifies end parameter works with empty args
  • All existing console print tests pass
  • Manual testing confirms behavior matches regular print()

Before

from rich.console import Console
console = Console()

print(end="!")  # Prints: !
console.print(end="!")  # Prints: \n (newline)

After

from rich.console import Console
console = Console()

print(end="!")  # Prints: !
console.print(end="!")  # Prints: ! (correctly)

When console.print() was called with no arguments but a custom end parameter,
it would print a newline instead of the end character. This was because empty
objects were replaced with NewLine() regardless of the end parameter.

Fixed by only using NewLine() when end is the default "\n", otherwise use
an empty Text object that will properly render with the custom end character.

Fixes Textualize#3701
@veeceey
Copy link
Author

veeceey commented Feb 8, 2026

Code changes verified ✓ Mergeable: YES | Ready for maintainer review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Behavior of console.print() with empty *args is different from regular print()

2 participants

Comments