Skip to content

Commit eea7070

Browse files
committed
Fix "AttributeError: 'str' object has no attribute 'decode'"
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 6b40e08 commit eea7070

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/attributecode/saneyaml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from functools import partial
2323

2424
import yaml
25+
import sys
2526

2627
try:
2728
from yaml import CSafeLoader as SafeLoader
@@ -171,7 +172,8 @@ def string_dumper(dumper, value, _tag=u'tag:yaml.org,2002:str'):
171172
value = repr(value)
172173

173174
if isinstance(value, str):
174-
value = value.decode('utf-8')
175+
if sys.version_info[0] < 3: # Python 2
176+
value = value.decode('utf-8')
175177

176178
folded_style = '>'
177179
verbatim_style = '|'

0 commit comments

Comments
 (0)