* [gentoo-commits] gentoo-x86 commit in dev-python/markupsafe/files: markupsafe-0.18-py3compat.patch
@ 2013-05-28 7:44 Ian Delaney (idella4)
0 siblings, 0 replies; 2+ messages in thread
From: Ian Delaney (idella4) @ 2013-05-28 7:44 UTC (permalink / raw
To: gentoo-commits
idella4 13/05/28 07:44:44
Added: markupsafe-0.18-py3compat.patch
Log:
bump, add patch to fix py3 support, fixes Bug #470952
(Portage version: 2.1.11.63/cvs/Linux x86_64, signed Manifest commit with key 0xB8072B0D)
Revision Changes Path
1.1 dev-python/markupsafe/files/markupsafe-0.18-py3compat.patch
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/markupsafe/files/markupsafe-0.18-py3compat.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/markupsafe/files/markupsafe-0.18-py3compat.patch?rev=1.1&content-type=text/plain
Index: markupsafe-0.18-py3compat.patch
===================================================================
https://github.com/tseaver/markupsafe/commit/553d9c3ba00e89967dfb608806f5703ef11c3f4c
diff --git a/CHANGES b/CHANGES
index 91a61c5..ec98481 100644
diff --git a/markupsafe/__init__.py b/markupsafe/__init__.py
index 25f00d3..902b2b2 100644
--- a/markupsafe/__init__.py
+++ b/markupsafe/__init__.py
@@ -10,12 +10,11 @@
"""
import re
from markupsafe._compat import text_type, string_types, int_types, \
- unichr, PY2
+ unichr, PY2, _EMPTY, _BLANK
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
-
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
_entity_re = re.compile(r'&([^;]+);')
@@ -65,7 +64,7 @@ class Markup(text_type):
"""
__slots__ = ()
- def __new__(cls, base=u'', encoding=None, errors='strict'):
+ def __new__(cls, base=_EMPTY, encoding=None, errors='strict'):
if hasattr(base, '__html__'):
base = base.__html__()
if encoding is None:
@@ -139,7 +138,7 @@ def handle_match(m):
return unichr(int(name[1:]))
except ValueError:
pass
- return u''
+ return _EMPTY
return _entity_re.sub(handle_match, text_type(self))
def striptags(self):
@@ -150,7 +149,7 @@ def striptags(self):
>>> Markup("Main » <em>About</em>").striptags()
u'Main \xbb About'
"""
- stripped = u' '.join(_striptags_re.sub('', self).split())
+ stripped = _BLANK.join(_striptags_re.sub('', self).split())
return Markup(stripped).unescape()
@classmethod
diff --git a/markupsafe/_compat.py b/markupsafe/_compat.py
index 29e4a3d..0cc647e 100644
--- a/markupsafe/_compat.py
+++ b/markupsafe/_compat.py
@@ -17,8 +17,18 @@
string_types = (str,)
unichr = chr
int_types = (int,)
+
+ def _u(s):
+ return s
+
else:
text_type = unicode
string_types = (str, unicode)
unichr = unichr
int_types = (int, long)
+
+ def _u(s):
+ return unicode(s, 'unicode_escape')
+
+_EMPTY = _u('')
+_BLANK = _u(' ')
diff --git a/markupsafe/tests.py b/markupsafe/tests.py
index b34cc6e..f2f71a4 100644
--- a/markupsafe/tests.py
+++ b/markupsafe/tests.py
@@ -2,7 +2,7 @@
import gc
import unittest
from markupsafe import Markup, escape, escape_silent
-from markupsafe._compat import text_type
+from markupsafe._compat import text_type, _u
class MarkupTestCase(unittest.TestCase):
@@ -48,16 +48,16 @@ def test_tuple_interpol(self):
self.assertEqual(Markup('<em>%s:%s</em>') % (
'<foo>',
'<bar>',
- ), Markup(u'<em><foo>:<bar></em>'))
+ ), Markup(_u('<em><foo>:<bar></em>')))
def test_dict_interpol(self):
self.assertEqual(Markup('<em>%(foo)s</em>') % {
'foo': '<foo>',
- }, Markup(u'<em><foo></em>'))
+ }, Markup(_u('<em><foo></em>')))
self.assertEqual(Markup('<em>%(foo)s:%(bar)s</em>') % {
'foo': '<foo>',
'bar': '<bar>',
- }, Markup(u'<em><foo>:<bar></em>'))
+ }, Markup(_u('<em><foo>:<bar></em>')))
def test_escaping(self):
# escaping and unescaping
@@ -73,7 +73,7 @@ def test_all_set(self):
def test_escape_silent(self):
assert escape_silent(None) == Markup()
assert escape(None) == Markup(None)
- assert escape_silent('<foo>') == Markup(u'<foo>')
+ assert escape_silent('<foo>') == Markup(_u('<foo>'))
def test_splitting(self):
self.assertEqual(Markup('a b').split(), [
@@ -101,8 +101,8 @@ def test_markup_leaks(self):
for item in range(1000):
escape("foo")
escape("<foo>")
- escape(u"foo")
- escape(u"<foo>")
+ escape(_u("foo"))
+ escape(_u("<foo>"))
counts.add(len(gc.get_objects()))
assert len(counts) == 1, 'ouch, c extension seems to leak objects'
diff --git a/setup.py b/setup.py
index a5ca3ef..cac6084 100644
--- a/setup.py
+++ b/setup.py
@@ -81,7 +81,12 @@ def run_setup(with_binary):
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.2',
+ 'Programming Language :: Python :: 3.3',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Text Processing :: Markup :: HTML'
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] gentoo-x86 commit in dev-python/markupsafe/files: markupsafe-0.18-py3compat.patch
@ 2015-02-01 16:35 Manuel Rueger (mrueg)
0 siblings, 0 replies; 2+ messages in thread
From: Manuel Rueger (mrueg) @ 2015-02-01 16:35 UTC (permalink / raw
To: gentoo-commits
mrueg 15/02/01 16:35:45
Removed: markupsafe-0.18-py3compat.patch
Log:
Remove old.
(Portage version: 2.2.15/cvs/Linux x86_64, signed Manifest commit with key )
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-01 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-01 16:35 [gentoo-commits] gentoo-x86 commit in dev-python/markupsafe/files: markupsafe-0.18-py3compat.patch Manuel Rueger (mrueg)
-- strict thread matches above, loose matches on Subject: below --
2013-05-28 7:44 Ian Delaney (idella4)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox