Fix bug with block_literal_representer

When serializing a block literal, be explicit that we want to treat it
as a string, instead of relying on implicit conversion.

Change-Id: I01a06c49f6112ef3e4313030ada0a7ea6adb5fb4
This commit is contained in:
Phil Sphicas 2020-09-09 06:31:40 +00:00
parent 4ed7005329
commit 88281bff56
1 changed files with 2 additions and 1 deletions

View File

@ -350,7 +350,8 @@ class block_literal(str):
def block_literal_representer(dumper, data):
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
return dumper.represent_scalar(
'tag:yaml.org,2002:str', str(data), style='|')
yaml.add_representer(block_literal, block_literal_representer)