Skip to content

Commit

Permalink
Make smartjoin return a str even if the argument is bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
aknrdureegaesr committed Dec 5, 2024
1 parent 48ec10d commit 6aa8d87
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nikola/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1947,10 +1947,10 @@ def smartjoin(join_char: str, string_or_iterable: Union[None, str, bytes, Iterab
'foo; bar'
>>> smartjoin(' to ', ['count', 42])
'count to 42'
The treatment of bytes (calling str(string_or_iterable)) is somewhat dubious. Is this needed?
"""
if isinstance(string_or_iterable, Iterable):
if isinstance(string_or_iterable, (str, bytes)):
return str(string_or_iterable)
elif isinstance(string_or_iterable, Iterable):
return join_char.join([str(e) for e in string_or_iterable])
else:
return str(string_or_iterable)
Expand Down

0 comments on commit 6aa8d87

Please sign in to comment.