diff options
author | Segev Finer <segev208@gmail.com> | 2018-10-14 19:38:11 +0300 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-08-07 18:52:38 -0700 |
commit | 1516dc6c80ff9f6aebfaf846126909650e451ad9 (patch) | |
tree | 4204b2ef07f890198dd2698fe3e9f655b1146eab /src/click/termui.py | |
parent | 66172ef2673bc7a7d718b36150a1e0b88b2959b1 (diff) | |
download | click-1516dc6c80ff9f6aebfaf846126909650e451ad9.tar.gz |
convert objects to string in style/secho
Diffstat (limited to 'src/click/termui.py')
-rw-r--r-- | src/click/termui.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/click/termui.py b/src/click/termui.py index fd3d915..a252ca6 100644 --- a/src/click/termui.py +++ b/src/click/termui.py @@ -482,11 +482,6 @@ def style( * ``bright_white`` * ``reset`` (reset the color code only) - .. versionadded:: 2.0 - - .. versionadded:: 7.0 - Added support for bright colors. - :param text: the string to style with ansi codes. :param fg: if provided this will become the foreground color. :param bg: if provided this will become the background color. @@ -501,7 +496,18 @@ def style( :param reset: by default a reset-all code is added at the end of the string which means that styles do not carry over. This can be disabled to compose styles. + + .. versionchanged:: 8.0 + A non-string ``message`` is converted to a string. + + .. versionchanged:: 7.0 + Added support for bright colors. + + .. versionadded:: 2.0 """ + if not isinstance(text, str): + text = str(text) + bits = [] if fg: try: @@ -551,6 +557,9 @@ def secho(message=None, file=None, nl=True, err=False, color=None, **styles): All keyword arguments are forwarded to the underlying functions depending on which one they go with. + .. versionchanged:: 8.0 + A non-string ``message`` is converted to a string. + .. versionadded:: 2.0 """ if message is not None: |