Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions wcwidth/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
>>> wcwidth.ljust('\U0001F468\u200D\U0001F469\u200D\U0001F467', 6)
'👨‍👩‍👧 '
"""
if text.isascii() and text.isprintable():
if len(fillchar) != 1:
raise TypeError('The fill character must be exactly one character long')
if text.isascii() and text.isprintable():

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
if text.isascii() and text.isprintable():
if text.isascii() and text.isprintable():

text_width = len(text)
else:
text_width = width(text, control_codes=control_codes, ambiguous_width=ambiguous_width,
Expand Down Expand Up @@ -98,7 +100,9 @@
>>> wcwidth.rjust('\U0001F468\u200D\U0001F469\u200D\U0001F467', 6)
' 👨‍👩‍👧'
"""
if text.isascii() and text.isprintable():
if len(fillchar) != 1:
raise TypeError('The fill character must be exactly one character long')
if text.isascii() and text.isprintable():

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
if text.isascii() and text.isprintable():
if text.isascii() and text.isprintable():

text_width = len(text)
else:
text_width = width(text, control_codes=control_codes, ambiguous_width=ambiguous_width,
Expand Down Expand Up @@ -153,7 +157,9 @@
>>> wcwidth.center('\U0001F468\u200D\U0001F469\u200D\U0001F467', 6)
' 👨‍👩‍👧 '
"""
if text.isascii() and text.isprintable():
if len(fillchar) != 1:
raise TypeError('The fill character must be exactly one character long')
if text.isascii() and text.isprintable():

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
if text.isascii() and text.isprintable():
if text.isascii() and text.isprintable():

text_width = len(text)
else:
text_width = width(text, control_codes=control_codes, ambiguous_width=ambiguous_width,
Expand Down
Loading