Skip to content

Commit

Permalink
fix(tone_convert): don't append tone number to empty input (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ban3 committed May 27, 2022
1 parent c426aa6 commit adbe233
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pypinyin/style/_tone_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def tone3_to_tone2(tone3, v_to_u=False):

def _improve_tone3(tone3, neutral_tone_with_five=False):
number = _get_number_from_pinyin(tone3)
if number is None and neutral_tone_with_five:
if number is None and neutral_tone_with_five and tone3 != '':
tone3 = '{}5'.format(tone3)
return tone3

Expand Down
2 changes: 2 additions & 0 deletions tests/contrib/test_tone_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def test_tone_tone3(pinyin, result):
@mark.parametrize('pinyin,neutral_tone_with_five,result', [
['shang', False, 'shang'],
['shang', True, 'shang5'],
['', False, ''],
['', True, '']
])
def test_tone_tone3_with_neutral_tone_with_five(
pinyin, neutral_tone_with_five, result):
Expand Down

0 comments on commit adbe233

Please sign in to comment.