summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2013-05-22 02:13:37 +0100
committerArmin Ronacher <armin.ronacher@active-4.com>2013-05-22 02:13:37 +0100
commit85488f43c3b2b0c8881ebccbccce17541f9e705d (patch)
tree6e19be2f6c24ec8f1ed8e7d303fd8edbdebd6087
parentd11c25e2d7fb9e1223b342e58baaa0400992f208 (diff)
downloadmarkupsafe-85488f43c3b2b0c8881ebccbccce17541f9e705d.tar.gz
Fixed __mul__ on Python 3
-rw-r--r--markupsafe/__init__.py7
-rw-r--r--markupsafe/_compat.py4
-rw-r--r--markupsafe/tests.py3
3 files changed, 9 insertions, 5 deletions
diff --git a/markupsafe/__init__.py b/markupsafe/__init__.py
index a6e744a..25f00d3 100644
--- a/markupsafe/__init__.py
+++ b/markupsafe/__init__.py
@@ -9,7 +9,8 @@
:license: BSD, see LICENSE for more details.
"""
import re
-from markupsafe._compat import text_type, string_types, imap, unichr, PY2
+from markupsafe._compat import text_type, string_types, int_types, \
+ unichr, PY2
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
@@ -85,7 +86,7 @@ class Markup(text_type):
return NotImplemented
def __mul__(self, num):
- if isinstance(num, (int, long)):
+ if isinstance(num, int_types):
return self.__class__(text_type.__mul__(self, num))
return NotImplemented
__rmul__ = __mul__
@@ -104,7 +105,7 @@ class Markup(text_type):
)
def join(self, seq):
- return self.__class__(text_type.join(self, imap(self.escape, seq)))
+ return self.__class__(text_type.join(self, map(self.escape, seq)))
join.__doc__ = text_type.join.__doc__
def split(self, *args, **kwargs):
diff --git a/markupsafe/_compat.py b/markupsafe/_compat.py
index 10627a6..29e4a3d 100644
--- a/markupsafe/_compat.py
+++ b/markupsafe/_compat.py
@@ -15,10 +15,10 @@ PY2 = sys.version_info[0] == 2
if not PY2:
text_type = str
string_types = (str,)
- imap = map
unichr = chr
+ int_types = (int,)
else:
text_type = unicode
string_types = (str, unicode)
- from itertools import imap
unichr = unichr
+ int_types = (int, long)
diff --git a/markupsafe/tests.py b/markupsafe/tests.py
index 703cfa6..b34cc6e 100644
--- a/markupsafe/tests.py
+++ b/markupsafe/tests.py
@@ -89,6 +89,9 @@ class MarkupTestCase(unittest.TestCase):
Markup('b')
])
+ def test_mul(self):
+ self.assertEqual(Markup('a') * 3, Markup('aaa'))
+
class MarkupLeakTestCase(unittest.TestCase):