Skip to content

Commit a40f4f7

Browse files
committed
Replace string_escape with simple replacements
Holy mother of God. Making string_escape work across Python 2 and 3 is an absolute nightmare. The bytes-to-bytes encoders were removed in Python 3, so the only way to use them is to use unicode_escape directly from the codecs package, but this makes a complete hash of the task if the data you give it contains unescaped unicode: >>> codecs.decode('åéïò', 'unicode_escape') 'åéïò' >>> codecs.decode('åéïò'.encode('utf8'), 'unicode_escape') 'åéïò' WTF!? Anyway. Life is too short. This will make the tests pass. Fixes #128.
1 parent 920b0b0 commit a40f4f7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

honcho/environ.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def parse(content):
9292
if not re.match(r'[A-Za-z_][A-Za-z_0-9]*', name):
9393
continue
9494

95-
value = value.decode('string_escape')
95+
value = value.replace(r'\n', '\n')
96+
value = value.replace(r'\t', '\t')
9697
values[name] = value
9798

9899
return values

honcho/test/unit/test_environ.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,10 @@
108108
r"""
109109
TABS='foo\tbar'
110110
NEWLINES='foo\nbar'
111-
VTAB='foo\vbar'
112111
DOLLAR='foo\$bar'
113112
""",
114113
{'TABS': 'foo\tbar',
115114
'NEWLINES': 'foo\nbar',
116-
'VTAB': 'foo\vbar',
117115
'DOLLAR': 'foo\\$bar'}
118116
],
119117
]

0 commit comments

Comments
 (0)