[Python-modules-commits] [markupsafe] 01/05: Import markupsafe_1.0.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Tue Jun 20 14:02:53 UTC 2017
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository markupsafe.
commit feb908e3c2d98649ff6c09fe115bc8b7edec158c
Author: Piotr Ożarowski <piotr at debian.org>
Date: Tue Jun 20 15:56:15 2017 +0200
Import markupsafe_1.0.orig.tar.gz
---
CHANGES | 48 ++++++++++++++++++++++++++
MANIFEST.in | 2 +-
MarkupSafe.egg-info/PKG-INFO | 76 ++++++++++++++++++++++++-----------------
MarkupSafe.egg-info/SOURCES.txt | 6 ++--
PKG-INFO | 76 ++++++++++++++++++++++++-----------------
README.rst | 70 ++++++++++++++++++++++---------------
markupsafe/__init__.py | 13 +++++--
markupsafe/_speedups.c | 6 ++--
setup.cfg | 3 ++
setup.py | 42 +++++++++++++++--------
markupsafe/tests.py => tests.py | 35 +++++++++++++++++--
11 files changed, 260 insertions(+), 117 deletions(-)
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..706a230
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,48 @@
+MarkupSafe Changelog
+====================
+
+Version 1.0
+-----------
+
+- Fixed custom types not invoking `__unicode__` when used
+ with `format()`.
+- Added `__version__` module attribute
+- Improve unescape code to leave lone ampersands alone.
+
+Version 0.18
+------------
+
+- Fixed `__mul__` and string splitting on Python 3.
+
+Version 0.17
+------------
+
+- Fixed a bug with broken interpolation on tuples.
+
+Version 0.16
+------------
+
+- Improved Python 3 Support and removed 2to3
+- Removed support for Python 3.2 and 2.5
+
+Version 0.15
+------------
+
+- Fixed a typo that caused the library to fail to install
+ on pypy and jython -.-
+
+Version 0.14
+------------
+
+- Release fix for 0.13.
+
+Version 0.13
+------------
+
+- Do not attempt to compile extension for PyPy or Jython.
+- Work around some 64bit Windows issues.
+
+Version 0.12
+------------
+
+- improved PyPy compatibility
diff --git a/MANIFEST.in b/MANIFEST.in
index d50e4e0..c9a1952 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,2 @@
-include LICENSE README.rst AUTHORS
+include AUTHORS CHANGES LICENSE tests.py
recursive-include markupsafe *.c
diff --git a/MarkupSafe.egg-info/PKG-INFO b/MarkupSafe.egg-info/PKG-INFO
index de4f27c..6f2568f 100644
--- a/MarkupSafe.egg-info/PKG-INFO
+++ b/MarkupSafe.egg-info/PKG-INFO
@@ -1,8 +1,8 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: MarkupSafe
-Version: 0.23
+Version: 1.0
Summary: Implements a XML/HTML/XHTML Markup safe string for Python
-Home-page: http://github.com/mitsuhiko/markupsafe
+Home-page: http://github.com/pallets/markupsafe
Author: Armin Ronacher
Author-email: armin.ronacher at active-4.com
License: BSD
@@ -11,49 +11,57 @@ Description: MarkupSafe
Implements a unicode subclass that supports HTML strings:
- >>> from markupsafe import Markup, escape
- >>> escape("<script>alert(document.cookie);</script>")
- Markup(u'<script>alert(document.cookie);</script>')
- >>> tmpl = Markup("<em>%s</em>")
- >>> tmpl % "Peter > Lustig"
- Markup(u'<em>Peter > Lustig</em>')
+ .. code-block:: python
+
+ >>> from markupsafe import Markup, escape
+ >>> escape("<script>alert(document.cookie);</script>")
+ Markup(u'<script>alert(document.cookie);</script>')
+ >>> tmpl = Markup("<em>%s</em>")
+ >>> tmpl % "Peter > Lustig"
+ Markup(u'<em>Peter > Lustig</em>')
If you want to make an object unicode that is not yet unicode
but don't want to lose the taint information, you can use the
- `soft_unicode` function. (On Python 3 you can also use `soft_str` which
+ ``soft_unicode`` function. (On Python 3 you can also use ``soft_str`` which
is a different name for the same function).
- >>> from markupsafe import soft_unicode
- >>> soft_unicode(42)
- u'42'
- >>> soft_unicode(Markup('foo'))
- Markup(u'foo')
+ .. code-block:: python
+
+ >>> from markupsafe import soft_unicode
+ >>> soft_unicode(42)
+ u'42'
+ >>> soft_unicode(Markup('foo'))
+ Markup(u'foo')
HTML Representations
--------------------
Objects can customize their HTML markup equivalent by overriding
- the `__html__` function:
+ the ``__html__`` function:
- >>> class Foo(object):
- ... def __html__(self):
- ... return '<strong>Nice</strong>'
- ...
- >>> escape(Foo())
- Markup(u'<strong>Nice</strong>')
- >>> Markup(Foo())
- Markup(u'<strong>Nice</strong>')
+ .. code-block:: python
+
+ >>> class Foo(object):
+ ... def __html__(self):
+ ... return '<strong>Nice</strong>'
+ ...
+ >>> escape(Foo())
+ Markup(u'<strong>Nice</strong>')
+ >>> Markup(Foo())
+ Markup(u'<strong>Nice</strong>')
Silent Escapes
--------------
Since MarkupSafe 0.10 there is now also a separate escape function
- called `escape_silent` that returns an empty string for `None` for
- consistency with other systems that return empty strings for `None`
+ called ``escape_silent`` that returns an empty string for ``None`` for
+ consistency with other systems that return empty strings for ``None``
when escaping (for instance Pylons' webhelpers).
If you also want to use this for the escape method of the Markup
- object, you can create your own subclass that does that::
+ object, you can create your own subclass that does that:
+
+ .. code-block:: python
from markupsafe import Markup, escape_silent as escape
@@ -79,7 +87,9 @@ Description: MarkupSafe
3. otherwise the default format system of Python kicks in and the result
is HTML escaped.
- Here is how you can implement your own formatting::
+ Here is how you can implement your own formatting:
+
+ .. code-block:: python
class User(object):
@@ -102,9 +112,13 @@ Description: MarkupSafe
And to format that user:
- >>> user = User(1, 'foo')
- >>> Markup('<p>User: {0:link}').format(user)
- Markup(u'<p>User: <a href="/user/1"><span class=user>foo</span></a>')
+ .. code-block:: python
+
+ >>> user = User(1, 'foo')
+ >>> Markup('<p>User: {0:link}').format(user)
+ Markup(u'<p>User: <a href="/user/1"><span class=user>foo</span></a>')
+
+ Markupsafe supports Python 2.6, 2.7 and Python 3.3 and higher.
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
diff --git a/MarkupSafe.egg-info/SOURCES.txt b/MarkupSafe.egg-info/SOURCES.txt
index b2e4482..210b339 100644
--- a/MarkupSafe.egg-info/SOURCES.txt
+++ b/MarkupSafe.egg-info/SOURCES.txt
@@ -1,8 +1,11 @@
AUTHORS
+CHANGES
LICENSE
MANIFEST.in
README.rst
+setup.cfg
setup.py
+tests.py
MarkupSafe.egg-info/PKG-INFO
MarkupSafe.egg-info/SOURCES.txt
MarkupSafe.egg-info/dependency_links.txt
@@ -12,5 +15,4 @@ markupsafe/__init__.py
markupsafe/_compat.py
markupsafe/_constants.py
markupsafe/_native.py
-markupsafe/_speedups.c
-markupsafe/tests.py
\ No newline at end of file
+markupsafe/_speedups.c
\ No newline at end of file
diff --git a/PKG-INFO b/PKG-INFO
index de4f27c..6f2568f 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,8 +1,8 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: MarkupSafe
-Version: 0.23
+Version: 1.0
Summary: Implements a XML/HTML/XHTML Markup safe string for Python
-Home-page: http://github.com/mitsuhiko/markupsafe
+Home-page: http://github.com/pallets/markupsafe
Author: Armin Ronacher
Author-email: armin.ronacher at active-4.com
License: BSD
@@ -11,49 +11,57 @@ Description: MarkupSafe
Implements a unicode subclass that supports HTML strings:
- >>> from markupsafe import Markup, escape
- >>> escape("<script>alert(document.cookie);</script>")
- Markup(u'<script>alert(document.cookie);</script>')
- >>> tmpl = Markup("<em>%s</em>")
- >>> tmpl % "Peter > Lustig"
- Markup(u'<em>Peter > Lustig</em>')
+ .. code-block:: python
+
+ >>> from markupsafe import Markup, escape
+ >>> escape("<script>alert(document.cookie);</script>")
+ Markup(u'<script>alert(document.cookie);</script>')
+ >>> tmpl = Markup("<em>%s</em>")
+ >>> tmpl % "Peter > Lustig"
+ Markup(u'<em>Peter > Lustig</em>')
If you want to make an object unicode that is not yet unicode
but don't want to lose the taint information, you can use the
- `soft_unicode` function. (On Python 3 you can also use `soft_str` which
+ ``soft_unicode`` function. (On Python 3 you can also use ``soft_str`` which
is a different name for the same function).
- >>> from markupsafe import soft_unicode
- >>> soft_unicode(42)
- u'42'
- >>> soft_unicode(Markup('foo'))
- Markup(u'foo')
+ .. code-block:: python
+
+ >>> from markupsafe import soft_unicode
+ >>> soft_unicode(42)
+ u'42'
+ >>> soft_unicode(Markup('foo'))
+ Markup(u'foo')
HTML Representations
--------------------
Objects can customize their HTML markup equivalent by overriding
- the `__html__` function:
+ the ``__html__`` function:
- >>> class Foo(object):
- ... def __html__(self):
- ... return '<strong>Nice</strong>'
- ...
- >>> escape(Foo())
- Markup(u'<strong>Nice</strong>')
- >>> Markup(Foo())
- Markup(u'<strong>Nice</strong>')
+ .. code-block:: python
+
+ >>> class Foo(object):
+ ... def __html__(self):
+ ... return '<strong>Nice</strong>'
+ ...
+ >>> escape(Foo())
+ Markup(u'<strong>Nice</strong>')
+ >>> Markup(Foo())
+ Markup(u'<strong>Nice</strong>')
Silent Escapes
--------------
Since MarkupSafe 0.10 there is now also a separate escape function
- called `escape_silent` that returns an empty string for `None` for
- consistency with other systems that return empty strings for `None`
+ called ``escape_silent`` that returns an empty string for ``None`` for
+ consistency with other systems that return empty strings for ``None``
when escaping (for instance Pylons' webhelpers).
If you also want to use this for the escape method of the Markup
- object, you can create your own subclass that does that::
+ object, you can create your own subclass that does that:
+
+ .. code-block:: python
from markupsafe import Markup, escape_silent as escape
@@ -79,7 +87,9 @@ Description: MarkupSafe
3. otherwise the default format system of Python kicks in and the result
is HTML escaped.
- Here is how you can implement your own formatting::
+ Here is how you can implement your own formatting:
+
+ .. code-block:: python
class User(object):
@@ -102,9 +112,13 @@ Description: MarkupSafe
And to format that user:
- >>> user = User(1, 'foo')
- >>> Markup('<p>User: {0:link}').format(user)
- Markup(u'<p>User: <a href="/user/1"><span class=user>foo</span></a>')
+ .. code-block:: python
+
+ >>> user = User(1, 'foo')
+ >>> Markup('<p>User: {0:link}').format(user)
+ Markup(u'<p>User: <a href="/user/1"><span class=user>foo</span></a>')
+
+ Markupsafe supports Python 2.6, 2.7 and Python 3.3 and higher.
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
diff --git a/README.rst b/README.rst
index 80a0996..360a087 100644
--- a/README.rst
+++ b/README.rst
@@ -3,49 +3,57 @@ MarkupSafe
Implements a unicode subclass that supports HTML strings:
->>> from markupsafe import Markup, escape
->>> escape("<script>alert(document.cookie);</script>")
-Markup(u'<script>alert(document.cookie);</script>')
->>> tmpl = Markup("<em>%s</em>")
->>> tmpl % "Peter > Lustig"
-Markup(u'<em>Peter > Lustig</em>')
+.. code-block:: python
+
+ >>> from markupsafe import Markup, escape
+ >>> escape("<script>alert(document.cookie);</script>")
+ Markup(u'<script>alert(document.cookie);</script>')
+ >>> tmpl = Markup("<em>%s</em>")
+ >>> tmpl % "Peter > Lustig"
+ Markup(u'<em>Peter > Lustig</em>')
If you want to make an object unicode that is not yet unicode
but don't want to lose the taint information, you can use the
-`soft_unicode` function. (On Python 3 you can also use `soft_str` which
+``soft_unicode`` function. (On Python 3 you can also use ``soft_str`` which
is a different name for the same function).
->>> from markupsafe import soft_unicode
->>> soft_unicode(42)
-u'42'
->>> soft_unicode(Markup('foo'))
-Markup(u'foo')
+.. code-block:: python
+
+ >>> from markupsafe import soft_unicode
+ >>> soft_unicode(42)
+ u'42'
+ >>> soft_unicode(Markup('foo'))
+ Markup(u'foo')
HTML Representations
--------------------
Objects can customize their HTML markup equivalent by overriding
-the `__html__` function:
+the ``__html__`` function:
->>> class Foo(object):
-... def __html__(self):
-... return '<strong>Nice</strong>'
-...
->>> escape(Foo())
-Markup(u'<strong>Nice</strong>')
->>> Markup(Foo())
-Markup(u'<strong>Nice</strong>')
+.. code-block:: python
+
+ >>> class Foo(object):
+ ... def __html__(self):
+ ... return '<strong>Nice</strong>'
+ ...
+ >>> escape(Foo())
+ Markup(u'<strong>Nice</strong>')
+ >>> Markup(Foo())
+ Markup(u'<strong>Nice</strong>')
Silent Escapes
--------------
Since MarkupSafe 0.10 there is now also a separate escape function
-called `escape_silent` that returns an empty string for `None` for
-consistency with other systems that return empty strings for `None`
+called ``escape_silent`` that returns an empty string for ``None`` for
+consistency with other systems that return empty strings for ``None``
when escaping (for instance Pylons' webhelpers).
If you also want to use this for the escape method of the Markup
-object, you can create your own subclass that does that::
+object, you can create your own subclass that does that:
+
+.. code-block:: python
from markupsafe import Markup, escape_silent as escape
@@ -71,7 +79,9 @@ following algorithm:
3. otherwise the default format system of Python kicks in and the result
is HTML escaped.
-Here is how you can implement your own formatting::
+Here is how you can implement your own formatting:
+
+.. code-block:: python
class User(object):
@@ -94,6 +104,10 @@ Here is how you can implement your own formatting::
And to format that user:
->>> user = User(1, 'foo')
->>> Markup('<p>User: {0:link}').format(user)
-Markup(u'<p>User: <a href="/user/1"><span class=user>foo</span></a>')
+.. code-block:: python
+
+ >>> user = User(1, 'foo')
+ >>> Markup('<p>User: {0:link}').format(user)
+ Markup(u'<p>User: <a href="/user/1"><span class=user>foo</span></a>')
+
+Markupsafe supports Python 2.6, 2.7 and Python 3.3 and higher.
diff --git a/markupsafe/__init__.py b/markupsafe/__init__.py
index 2755401..68dc85f 100644
--- a/markupsafe/__init__.py
+++ b/markupsafe/__init__.py
@@ -14,12 +14,13 @@ from collections import Mapping
from markupsafe._compat import text_type, string_types, int_types, \
unichr, iteritems, PY2
+__version__ = "1.0"
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
-_entity_re = re.compile(r'&([^;]+);')
+_entity_re = re.compile(r'&([^& ;]+);')
class Markup(text_type):
@@ -142,7 +143,8 @@ class Markup(text_type):
return unichr(int(name[1:]))
except ValueError:
pass
- return u''
+ # Don't modify unexpected input.
+ return m.group()
return _entity_re.sub(handle_match, text_type(self))
def striptags(self):
@@ -260,7 +262,12 @@ if hasattr(text_type, 'format'):
'its __html__ method.')
rv = value.__html__()
else:
- rv = string.Formatter.format_field(self, value, format_spec)
+ # We need to make sure the format spec is unicode here as
+ # otherwise the wrong callback methods are invoked. For
+ # instance a byte string there would invoke __str__ and
+ # not __unicode__.
+ rv = string.Formatter.format_field(
+ self, value, text_type(format_spec))
return text_type(self.escape(rv))
diff --git a/markupsafe/_speedups.c b/markupsafe/_speedups.c
index f349feb..d779a68 100644
--- a/markupsafe/_speedups.c
+++ b/markupsafe/_speedups.c
@@ -29,7 +29,7 @@ static int
init_constants(void)
{
PyObject *module;
- /* happing of characters to replace */
+ /* mapping of characters to replace */
escaped_chars_repl['"'] = UNICHR(""");
escaped_chars_repl['\''] = UNICHR("'");
escaped_chars_repl['&'] = UNICHR("&");
@@ -41,7 +41,7 @@ init_constants(void)
escaped_chars_delta_len['"'] = escaped_chars_delta_len['\''] = \
escaped_chars_delta_len['&'] = 4;
escaped_chars_delta_len['<'] = escaped_chars_delta_len['>'] = 3;
-
+
/* import markup type so that we can mark the return value */
module = PyImport_ImportModule("markupsafe");
if (!module)
@@ -94,7 +94,7 @@ escape_unicode(PyUnicodeObject *in)
}
++next_escp;
}
-
+
if (next_escp > inp) {
/* copy unescaped chars between inp and next_escp */
Py_UNICODE_COPY(outp, inp, next_escp-inp);
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..2a37914 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,3 +1,6 @@
+[metadata]
+license_file = LICENSE
+
[egg_info]
tag_build =
tag_date = 0
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
index d7bb2c3..e30df8e
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,9 @@
+#!/usr/bin/env python
import os
+import re
+import ast
import sys
-from setuptools import setup, Extension
+from setuptools import setup, Extension, Feature
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
@@ -12,21 +15,29 @@ from distutils.errors import CCompilerError, DistutilsExecError, \
is_jython = 'java' in sys.platform
is_pypy = hasattr(sys, 'pypy_version_info')
+with open('markupsafe/__init__.py') as f:
+ version = ast.literal_eval(re.search(
+ '^__version__\s+=\s+(.*?)$(?sm)', f.read()).group(1))
-# Remove old arguments that were once supported. Thanks setuptools
-# 3.0 for just randomly removing functionality.
-for arg in '--with-speedups', '--without-speedups':
- try:
- sys.argv.remove(arg)
- except ValueError:
- pass
+speedups = Feature(
+ 'optional C speed-enhancement module',
+ standard=True,
+ ext_modules=[
+ Extension('markupsafe._speedups', ['markupsafe/_speedups.c']),
+ ],
+)
+# Known errors when running build_ext.build_extension method
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
if sys.platform == 'win32' and sys.version_info > (2, 6):
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
ext_errors += (IOError,)
+# Known errors when running build_ext.run method
+run_errors = (DistutilsPlatformError,)
+if sys.platform == 'darwin':
+ run_errors += (SystemError,)
class BuildFailed(Exception):
@@ -39,7 +50,7 @@ class ve_build_ext(build_ext):
def run(self):
try:
build_ext.run(self)
- except DistutilsPlatformError:
+ except run_errors:
raise BuildFailed()
def build_extension(self, ext):
@@ -62,12 +73,13 @@ readme = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
def run_setup(with_binary):
- ext = Extension('markupsafe._speedups', ['markupsafe/_speedups.c'])
- ext_modules = [ext] if with_binary else []
+ features = {}
+ if with_binary:
+ features['speedups'] = speedups
setup(
name='MarkupSafe',
- version='0.23',
- url='http://github.com/mitsuhiko/markupsafe',
+ version=version,
+ url='http://github.com/pallets/markupsafe',
license='BSD',
author='Armin Ronacher',
author_email='armin.ronacher at active-4.com',
@@ -87,10 +99,10 @@ def run_setup(with_binary):
'Topic :: Text Processing :: Markup :: HTML'
],
packages=['markupsafe'],
- test_suite='markupsafe.tests.suite',
+ test_suite='tests.suite',
include_package_data=True,
cmdclass={'build_ext': ve_build_ext},
- ext_modules=ext_modules,
+ features=features,
)
diff --git a/markupsafe/tests.py b/tests.py
old mode 100644
new mode 100755
similarity index 83%
rename from markupsafe/tests.py
rename to tests.py
index 6369936..7ec2acb
--- a/markupsafe/tests.py
+++ b/tests.py
@@ -1,9 +1,10 @@
+#!/usr/bin/env python
# -*- coding: utf-8 -*-
import gc
import sys
import unittest
from markupsafe import Markup, escape, escape_silent
-from markupsafe._compat import text_type
+from markupsafe._compat import text_type, PY2
class MarkupTestCase(unittest.TestCase):
@@ -61,10 +62,22 @@ class MarkupTestCase(unittest.TestCase):
}, Markup(u'<em><foo>:<bar></em>'))
def test_escaping(self):
- # escaping and unescaping
+ # escaping
assert escape('"<>&\'') == '"<>&''
assert Markup("<em>Foo & Bar</em>").striptags() == "Foo & Bar"
+
+ def test_unescape(self):
assert Markup("<test>").unescape() == "<test>"
+ assert "jack & tavi are cooler than mike & russ" == \
+ Markup("jack & tavi are cooler than mike & russ").unescape(), \
+ Markup("jack & tavi are cooler than mike & russ").unescape()
+
+ # Test that unescape is idempotent
+ original = '&foo;'
+ once = Markup(original).unescape()
+ twice = Markup(once).unescape()
+ expected = "&foo;"
+ assert expected == once == twice, (once, twice)
def test_formatting(self):
for actual, expected in (
@@ -120,6 +133,19 @@ class MarkupTestCase(unittest.TestCase):
assert Markup('<p>User: {0:link}').format(user) == \
Markup('<p>User: <a href="/user/1"><span class=user>foo</span></a>')
+ def test_formatting_with_objects(self):
+ class Stringable(object):
+ def __unicode__(self):
+ return u'строка'
+ if PY2:
+ def __str__(self):
+ return 'some other value'
+ else:
+ __str__ = __unicode__
+
+ assert Markup('{s}').format(s=Stringable()) == \
+ Markup(u'строка')
+
def test_all_set(self):
import markupsafe as markup
for item in markup.__all__:
@@ -158,8 +184,11 @@ class MarkupLeakTestCase(unittest.TestCase):
escape("<foo>")
escape(u"foo")
escape(u"<foo>")
+ if hasattr(sys, 'pypy_version_info'):
+ gc.collect()
counts.add(len(gc.get_objects()))
- assert len(counts) == 1, 'ouch, c extension seems to leak objects'
+ assert len(counts) == 1, 'ouch, c extension seems to ' \
+ 'leak objects, got: ' + str(len(counts))
def suite():
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/markupsafe.git
More information about the Python-modules-commits
mailing list