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: Ia79600ebc228d8417342a0703167f34703169d5a
This commit is contained in:
Phil Sphicas 2020-09-09 06:11:52 +00:00
parent 9853fcfbee
commit 6d7df808f3
1 changed files with 2 additions and 1 deletions

View File

@ -193,7 +193,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)