You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2021/09/10 16:38:41 UTC
[allura] branch master updated: Let really_unicode() preserve
Markup types. Probably faster in most cases too
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new e68e68d Let really_unicode() preserve Markup types. Probably faster in most cases too
e68e68d is described below
commit e68e68dbead04c32c9c58922ef1625ef363f5b99
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Wed Sep 8 15:27:38 2021 -0400
Let really_unicode() preserve Markup types. Probably faster in most cases too
---
Allura/allura/lib/helpers.py | 3 +++
Allura/allura/tests/test_helpers.py | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 94f7713..79f8ad8 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -240,6 +240,9 @@ def _attempt_encodings(s, encodings):
def really_unicode(s):
+ if isinstance(s, str):
+ # default case. Also lets Markup() instances be preserved
+ return s
# Try to guess the encoding
def encodings():
yield None
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 1a2935d..4e35c01 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -116,6 +116,11 @@ def test_really_unicode():
assert_equals(h.really_unicode(1234), '1234')
assert_equals(h.really_unicode(datetime(2020, 1, 1)), '2020-01-01 00:00:00')
assert_equals(h.really_unicode(None), '')
+ # markup stays markup
+ s = h.really_unicode(Markup('<b>test</b>'))
+ assert isinstance(s, six.text_type)
+ assert isinstance(s, Markup)
+ assert_equals(s, '<b>test</b>')
def test_find_project():