1 |
idella4 13/05/28 07:44:44 |
2 |
|
3 |
Added: markupsafe-0.18-py3compat.patch |
4 |
Log: |
5 |
bump, add patch to fix py3 support, fixes Bug #470952 |
6 |
|
7 |
(Portage version: 2.1.11.63/cvs/Linux x86_64, signed Manifest commit with key 0xB8072B0D) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 dev-python/markupsafe/files/markupsafe-0.18-py3compat.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/markupsafe/files/markupsafe-0.18-py3compat.patch?rev=1.1&view=markup |
13 |
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 |
14 |
|
15 |
Index: markupsafe-0.18-py3compat.patch |
16 |
=================================================================== |
17 |
https://github.com/tseaver/markupsafe/commit/553d9c3ba00e89967dfb608806f5703ef11c3f4c |
18 |
diff --git a/CHANGES b/CHANGES |
19 |
index 91a61c5..ec98481 100644 |
20 |
diff --git a/markupsafe/__init__.py b/markupsafe/__init__.py |
21 |
index 25f00d3..902b2b2 100644 |
22 |
--- a/markupsafe/__init__.py |
23 |
+++ b/markupsafe/__init__.py |
24 |
@@ -10,12 +10,11 @@ |
25 |
""" |
26 |
import re |
27 |
from markupsafe._compat import text_type, string_types, int_types, \ |
28 |
- unichr, PY2 |
29 |
+ unichr, PY2, _EMPTY, _BLANK |
30 |
|
31 |
|
32 |
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent'] |
33 |
|
34 |
- |
35 |
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)') |
36 |
_entity_re = re.compile(r'&([^;]+);') |
37 |
|
38 |
@@ -65,7 +64,7 @@ class Markup(text_type): |
39 |
""" |
40 |
__slots__ = () |
41 |
|
42 |
- def __new__(cls, base=u'', encoding=None, errors='strict'): |
43 |
+ def __new__(cls, base=_EMPTY, encoding=None, errors='strict'): |
44 |
if hasattr(base, '__html__'): |
45 |
base = base.__html__() |
46 |
if encoding is None: |
47 |
@@ -139,7 +138,7 @@ def handle_match(m): |
48 |
return unichr(int(name[1:])) |
49 |
except ValueError: |
50 |
pass |
51 |
- return u'' |
52 |
+ return _EMPTY |
53 |
return _entity_re.sub(handle_match, text_type(self)) |
54 |
|
55 |
def striptags(self): |
56 |
@@ -150,7 +149,7 @@ def striptags(self): |
57 |
>>> Markup("Main » <em>About</em>").striptags() |
58 |
u'Main \xbb About' |
59 |
""" |
60 |
- stripped = u' '.join(_striptags_re.sub('', self).split()) |
61 |
+ stripped = _BLANK.join(_striptags_re.sub('', self).split()) |
62 |
return Markup(stripped).unescape() |
63 |
|
64 |
@classmethod |
65 |
diff --git a/markupsafe/_compat.py b/markupsafe/_compat.py |
66 |
index 29e4a3d..0cc647e 100644 |
67 |
--- a/markupsafe/_compat.py |
68 |
+++ b/markupsafe/_compat.py |
69 |
@@ -17,8 +17,18 @@ |
70 |
string_types = (str,) |
71 |
unichr = chr |
72 |
int_types = (int,) |
73 |
+ |
74 |
+ def _u(s): |
75 |
+ return s |
76 |
+ |
77 |
else: |
78 |
text_type = unicode |
79 |
string_types = (str, unicode) |
80 |
unichr = unichr |
81 |
int_types = (int, long) |
82 |
+ |
83 |
+ def _u(s): |
84 |
+ return unicode(s, 'unicode_escape') |
85 |
+ |
86 |
+_EMPTY = _u('') |
87 |
+_BLANK = _u(' ') |
88 |
diff --git a/markupsafe/tests.py b/markupsafe/tests.py |
89 |
index b34cc6e..f2f71a4 100644 |
90 |
--- a/markupsafe/tests.py |
91 |
+++ b/markupsafe/tests.py |
92 |
@@ -2,7 +2,7 @@ |
93 |
import gc |
94 |
import unittest |
95 |
from markupsafe import Markup, escape, escape_silent |
96 |
-from markupsafe._compat import text_type |
97 |
+from markupsafe._compat import text_type, _u |
98 |
|
99 |
|
100 |
class MarkupTestCase(unittest.TestCase): |
101 |
@@ -48,16 +48,16 @@ def test_tuple_interpol(self): |
102 |
self.assertEqual(Markup('<em>%s:%s</em>') % ( |
103 |
'<foo>', |
104 |
'<bar>', |
105 |
- ), Markup(u'<em><foo>:<bar></em>')) |
106 |
+ ), Markup(_u('<em><foo>:<bar></em>'))) |
107 |
|
108 |
def test_dict_interpol(self): |
109 |
self.assertEqual(Markup('<em>%(foo)s</em>') % { |
110 |
'foo': '<foo>', |
111 |
- }, Markup(u'<em><foo></em>')) |
112 |
+ }, Markup(_u('<em><foo></em>'))) |
113 |
self.assertEqual(Markup('<em>%(foo)s:%(bar)s</em>') % { |
114 |
'foo': '<foo>', |
115 |
'bar': '<bar>', |
116 |
- }, Markup(u'<em><foo>:<bar></em>')) |
117 |
+ }, Markup(_u('<em><foo>:<bar></em>'))) |
118 |
|
119 |
def test_escaping(self): |
120 |
# escaping and unescaping |
121 |
@@ -73,7 +73,7 @@ def test_all_set(self): |
122 |
def test_escape_silent(self): |
123 |
assert escape_silent(None) == Markup() |
124 |
assert escape(None) == Markup(None) |
125 |
- assert escape_silent('<foo>') == Markup(u'<foo>') |
126 |
+ assert escape_silent('<foo>') == Markup(_u('<foo>')) |
127 |
|
128 |
def test_splitting(self): |
129 |
self.assertEqual(Markup('a b').split(), [ |
130 |
@@ -101,8 +101,8 @@ def test_markup_leaks(self): |
131 |
for item in range(1000): |
132 |
escape("foo") |
133 |
escape("<foo>") |
134 |
- escape(u"foo") |
135 |
- escape(u"<foo>") |
136 |
+ escape(_u("foo")) |
137 |
+ escape(_u("<foo>")) |
138 |
counts.add(len(gc.get_objects())) |
139 |
assert len(counts) == 1, 'ouch, c extension seems to leak objects' |
140 |
|
141 |
diff --git a/setup.py b/setup.py |
142 |
index a5ca3ef..cac6084 100644 |
143 |
--- a/setup.py |
144 |
+++ b/setup.py |
145 |
@@ -81,7 +81,12 @@ def run_setup(with_binary): |
146 |
'License :: OSI Approved :: BSD License', |
147 |
'Operating System :: OS Independent', |
148 |
'Programming Language :: Python', |
149 |
+ 'Programming Language :: Python :: 2', |
150 |
+ 'Programming Language :: Python :: 2.6', |
151 |
+ 'Programming Language :: Python :: 2.7', |
152 |
'Programming Language :: Python :: 3', |
153 |
+ 'Programming Language :: Python :: 3.2', |
154 |
+ 'Programming Language :: Python :: 3.3', |
155 |
'Topic :: Internet :: WWW/HTTP :: Dynamic Content', |
156 |
'Topic :: Software Development :: Libraries :: Python Modules', |
157 |
'Topic :: Text Processing :: Markup :: HTML' |