26 lines
1.1 KiB
Diff
26 lines
1.1 KiB
Diff
From c6f390b45be689a5760060c990e3fe10f502e671 Mon Sep 17 00:00:00 2001
|
|
From: "Franklin \"Snaipe\" Mathieu" <snaipe@arista.com>
|
|
Date: Mon, 25 Jan 2021 18:06:51 +0100
|
|
Subject: [PATCH 2/2] api: fix AttributeError on decode when feeding unicode
|
|
strings in python3
|
|
|
|
Fixes #12, #13
|
|
---
|
|
rst2ansi/__init__.py | 5 ++++-
|
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/rst2ansi/__init__.py b/rst2ansi/__init__.py
|
|
index f0665f4..0ea9a97 100644
|
|
--- a/rst2ansi/__init__.py
|
|
+++ b/rst2ansi/__init__.py
|
|
@@ -45,5 +45,8 @@ def style_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
for style in STYLES:
|
|
roles.register_local_role('ansi-' + style, style_role)
|
|
|
|
- out = core.publish_string(input_string.decode('utf-8'), settings_overrides=overrides, writer=Writer(unicode=output_encoding.startswith('utf')))
|
|
+ if hasattr(input_string, 'decode'):
|
|
+ input_string = input_string.decode('utf-8')
|
|
+
|
|
+ out = core.publish_string(input_string, settings_overrides=overrides, writer=Writer(unicode=output_encoding.startswith('utf')))
|
|
return out.decode(output_encoding)
|