Hello community, here is the log from the commit of package python-MarkupSafe for openSUSE:Factory checked in at 2017-04-19 18:07:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-MarkupSafe (Old) and /work/SRC/openSUSE:Factory/.python-MarkupSafe.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-MarkupSafe" Wed Apr 19 18:07:16 2017 rev:18 rq:485684 version:1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-MarkupSafe/python-MarkupSafe.changes 2014-07-16 16:37:14.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-MarkupSafe.new/python-MarkupSafe.changes 2017-04-19 18:07:17.319862241 +0200 @@ -1,0 +2,19 @@ +Tue Apr 4 15:13:20 UTC 2017 - [email protected] + +- update source url +- fix obs/prov to refer to old python +- drop _speedups.c from installed directory + +------------------------------------------------------------------- +Wed Mar 22 15:11:29 UTC 2017 - [email protected] + +- Add missing BuildRequires for python-rpm-macros + +------------------------------------------------------------------- +Wed Mar 22 13:08:44 UTC 2017 - [email protected] + +- update to 1.0.0 + + No upstream changelog +- Switch to singlespec approach + +------------------------------------------------------------------- Old: ---- MarkupSafe-0.23.tar.gz New: ---- MarkupSafe-1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-MarkupSafe.spec ++++++ --- /var/tmp/diff_new_pack.Qm4cQD/_old 2017-04-19 18:07:17.963771157 +0200 +++ /var/tmp/diff_new_pack.Qm4cQD/_new 2017-04-19 18:07:17.963771157 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-MarkupSafe # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,23 +16,26 @@ # +%define oldpython python +%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-MarkupSafe -Version: 0.23 +Version: 1.0 Release: 0 Url: http://dev.pocoo.org/ Summary: Implements a XML/HTML/XHTML Markup safe string for Python License: BSD-3-Clause Group: Development/Languages/Python -Source: http://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-%{version}.tar.gz +Source: https://files.pythonhosted.org/packages/source/M/MarkupSafe/MarkupSafe-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: python-devel -BuildRequires: python-setuptools -%if 0%{?suse_version} -%py_requires +BuildRequires: %{python_module devel} +BuildRequires: %{python_module setuptools} +BuildRequires: python-rpm-macros +%ifpython2 +Provides: %{oldpython}-markupsafe = %{version} +Obsoletes: %{oldpython}-markupsafe < %{version} %endif -Provides: python-markupsafe = %{version} -Obsoletes: python-markupsafe < %{version} -%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} + +%python_subpackages %description Implements a unicode subclass that supports HTML strings. This can be used to @@ -42,15 +45,17 @@ %setup -q -n MarkupSafe-%{version} %build -CFLAGS="%{optflags}" python setup.py build +export CFLAGS="%{optflags}" +%python_build %install -python setup.py install --prefix=%{_prefix} --root=%{buildroot} +%python_install +%python_expand rm %{buildroot}%{$python_sitearch}/markupsafe/_speedups.c %check -python setup.py test +%python_exec setup.py test -%files +%files %python_files %defattr(-,root,root,-) %doc AUTHORS LICENSE README.rst %{python_sitearch}/markupsafe/ ++++++ MarkupSafe-0.23.tar.gz -> MarkupSafe-1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/CHANGES new/MarkupSafe-1.0/CHANGES --- old/MarkupSafe-0.23/CHANGES 1970-01-01 01:00:00.000000000 +0100 +++ new/MarkupSafe-1.0/CHANGES 2016-01-13 22:37:41.000000000 +0100 @@ -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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/MANIFEST.in new/MarkupSafe-1.0/MANIFEST.in --- old/MarkupSafe-0.23/MANIFEST.in 2013-05-20 18:08:35.000000000 +0200 +++ new/MarkupSafe-1.0/MANIFEST.in 2017-03-07 16:30:16.000000000 +0100 @@ -1,2 +1,2 @@ -include LICENSE README.rst AUTHORS +include AUTHORS CHANGES LICENSE tests.py recursive-include markupsafe *.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/MarkupSafe.egg-info/PKG-INFO new/MarkupSafe-1.0/MarkupSafe.egg-info/PKG-INFO --- old/MarkupSafe-0.23/MarkupSafe.egg-info/PKG-INFO 2014-05-08 16:58:52.000000000 +0200 +++ new/MarkupSafe-1.0/MarkupSafe.egg-info/PKG-INFO 2017-03-07 16:32:10.000000000 +0100 @@ -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: [email protected] License: BSD @@ -11,49 +11,57 @@ 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 @@ 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 @@ 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/MarkupSafe.egg-info/SOURCES.txt new/MarkupSafe-1.0/MarkupSafe.egg-info/SOURCES.txt --- old/MarkupSafe-0.23/MarkupSafe.egg-info/SOURCES.txt 2014-05-08 16:58:52.000000000 +0200 +++ new/MarkupSafe-1.0/MarkupSafe.egg-info/SOURCES.txt 2017-03-07 16:32:11.000000000 +0100 @@ -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/_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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/PKG-INFO new/MarkupSafe-1.0/PKG-INFO --- old/MarkupSafe-0.23/PKG-INFO 2014-05-08 16:58:52.000000000 +0200 +++ new/MarkupSafe-1.0/PKG-INFO 2017-03-07 16:32:11.000000000 +0100 @@ -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: [email protected] License: BSD @@ -11,49 +11,57 @@ 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 @@ 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 @@ 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/README.rst new/MarkupSafe-1.0/README.rst --- old/MarkupSafe-0.23/README.rst 2014-04-17 11:58:15.000000000 +0200 +++ new/MarkupSafe-1.0/README.rst 2017-03-07 16:30:16.000000000 +0100 @@ -3,49 +3,57 @@ 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 @@ 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 @@ 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/markupsafe/__init__.py new/MarkupSafe-1.0/markupsafe/__init__.py --- old/MarkupSafe-0.23/markupsafe/__init__.py 2014-05-08 16:52:34.000000000 +0200 +++ new/MarkupSafe-1.0/markupsafe/__init__.py 2017-03-07 16:30:39.000000000 +0100 @@ -14,12 +14,13 @@ 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 @@ 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 @@ '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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/markupsafe/_speedups.c new/MarkupSafe-1.0/markupsafe/_speedups.c --- old/MarkupSafe-0.23/markupsafe/_speedups.c 2013-05-20 18:08:35.000000000 +0200 +++ new/MarkupSafe-1.0/markupsafe/_speedups.c 2016-01-13 22:34:58.000000000 +0100 @@ -29,7 +29,7 @@ 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 @@ 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 @@ } ++next_escp; } - + if (next_escp > inp) { /* copy unescaped chars between inp and next_escp */ Py_UNICODE_COPY(outp, inp, next_escp-inp); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/markupsafe/tests.py new/MarkupSafe-1.0/markupsafe/tests.py --- old/MarkupSafe-0.23/markupsafe/tests.py 2014-05-08 16:58:28.000000000 +0200 +++ new/MarkupSafe-1.0/markupsafe/tests.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,179 +0,0 @@ -# -*- coding: utf-8 -*- -import gc -import sys -import unittest -from markupsafe import Markup, escape, escape_silent -from markupsafe._compat import text_type - - -class MarkupTestCase(unittest.TestCase): - - def test_adding(self): - # adding two strings should escape the unsafe one - unsafe = '<script type="application/x-some-script">alert("foo");</script>' - safe = Markup('<em>username</em>') - assert unsafe + safe == text_type(escape(unsafe)) + text_type(safe) - - def test_string_interpolation(self): - # string interpolations are safe to use too - assert Markup('<em>%s</em>') % '<bad user>' == \ - '<em><bad user></em>' - assert Markup('<em>%(username)s</em>') % { - 'username': '<bad user>' - } == '<em><bad user></em>' - - assert Markup('%i') % 3.14 == '3' - assert Markup('%.2f') % 3.14 == '3.14' - - def test_type_behavior(self): - # an escaped object is markup too - assert type(Markup('foo') + 'bar') is Markup - - # and it implements __html__ by returning itself - x = Markup("foo") - assert x.__html__() is x - - def test_html_interop(self): - # it also knows how to treat __html__ objects - class Foo(object): - def __html__(self): - return '<em>awesome</em>' - def __unicode__(self): - return 'awesome' - __str__ = __unicode__ - assert Markup(Foo()) == '<em>awesome</em>' - assert Markup('<strong>%s</strong>') % Foo() == \ - '<strong><em>awesome</em></strong>' - - def test_tuple_interpol(self): - self.assertEqual(Markup('<em>%s:%s</em>') % ( - '<foo>', - '<bar>', - ), 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>')) - self.assertEqual(Markup('<em>%(foo)s:%(bar)s</em>') % { - 'foo': '<foo>', - 'bar': '<bar>', - }, Markup(u'<em><foo>:<bar></em>')) - - def test_escaping(self): - # escaping and unescaping - assert escape('"<>&\'') == '"<>&'' - assert Markup("<em>Foo & Bar</em>").striptags() == "Foo & Bar" - assert Markup("<test>").unescape() == "<test>" - - def test_formatting(self): - for actual, expected in ( - (Markup('%i') % 3.14, '3'), - (Markup('%.2f') % 3.14159, '3.14'), - (Markup('%s %s %s') % ('<', 123, '>'), '< 123 >'), - (Markup('<em>{awesome}</em>').format(awesome='<awesome>'), - '<em><awesome></em>'), - (Markup('{0[1][bar]}').format([0, {'bar': '<bar/>'}]), - '<bar/>'), - (Markup('{0[1][bar]}').format([0, {'bar': Markup('<bar/>')}]), - '<bar/>')): - assert actual == expected, "%r should be %r!" % (actual, expected) - - # This is new in 2.7 - if sys.version_info >= (2, 7): - def test_formatting_empty(self): - formatted = Markup('{}').format(0) - assert formatted == Markup('0') - - def test_custom_formatting(self): - class HasHTMLOnly(object): - def __html__(self): - return Markup('<foo>') - - class HasHTMLAndFormat(object): - def __html__(self): - return Markup('<foo>') - def __html_format__(self, spec): - return Markup('<FORMAT>') - - assert Markup('{0}').format(HasHTMLOnly()) == Markup('<foo>') - assert Markup('{0}').format(HasHTMLAndFormat()) == Markup('<FORMAT>') - - def test_complex_custom_formatting(self): - class User(object): - def __init__(self, id, username): - self.id = id - self.username = username - def __html_format__(self, format_spec): - if format_spec == 'link': - return Markup('<a href="/user/{0}">{1}</a>').format( - self.id, - self.__html__(), - ) - elif format_spec: - raise ValueError('Invalid format spec') - return self.__html__() - def __html__(self): - return Markup('<span class=user>{0}</span>').format(self.username) - - user = User(1, 'foo') - assert Markup('<p>User: {0:link}').format(user) == \ - Markup('<p>User: <a href="/user/1"><span class=user>foo</span></a>') - - def test_all_set(self): - import markupsafe as markup - for item in markup.__all__: - getattr(markup, item) - - def test_escape_silent(self): - assert escape_silent(None) == Markup() - assert escape(None) == Markup(None) - assert escape_silent('<foo>') == Markup(u'<foo>') - - def test_splitting(self): - self.assertEqual(Markup('a b').split(), [ - Markup('a'), - Markup('b') - ]) - self.assertEqual(Markup('a b').rsplit(), [ - Markup('a'), - Markup('b') - ]) - self.assertEqual(Markup('a\nb').splitlines(), [ - Markup('a'), - Markup('b') - ]) - - def test_mul(self): - self.assertEqual(Markup('a') * 3, Markup('aaa')) - - -class MarkupLeakTestCase(unittest.TestCase): - - def test_markup_leaks(self): - counts = set() - for count in range(20): - for item in range(1000): - escape("foo") - escape("<foo>") - escape(u"foo") - escape(u"<foo>") - counts.add(len(gc.get_objects())) - assert len(counts) == 1, 'ouch, c extension seems to leak objects' - - -def suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(MarkupTestCase)) - - # this test only tests the c extension - if not hasattr(escape, 'func_code'): - suite.addTest(unittest.makeSuite(MarkupLeakTestCase)) - - return suite - - -if __name__ == '__main__': - unittest.main(defaultTest='suite') - -# vim:sts=4:sw=4:et: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/setup.cfg new/MarkupSafe-1.0/setup.cfg --- old/MarkupSafe-0.23/setup.cfg 2014-05-08 16:58:52.000000000 +0200 +++ new/MarkupSafe-1.0/setup.cfg 2017-03-07 16:32:11.000000000 +0100 @@ -1,3 +1,6 @@ +[metadata] +license_file = LICENSE + [egg_info] tag_build = tag_date = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/setup.py new/MarkupSafe-1.0/setup.py --- old/MarkupSafe-0.23/setup.py 2014-05-08 16:58:40.000000000 +0200 +++ new/MarkupSafe-1.0/setup.py 2017-03-07 16:30:16.000000000 +0100 @@ -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 @@ 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 @@ def run(self): try: build_ext.run(self) - except DistutilsPlatformError: + except run_errors: raise BuildFailed() def build_extension(self, ext): @@ -62,12 +73,13 @@ 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='[email protected]', @@ -87,10 +99,10 @@ '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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MarkupSafe-0.23/tests.py new/MarkupSafe-1.0/tests.py --- old/MarkupSafe-0.23/tests.py 1970-01-01 01:00:00.000000000 +0100 +++ new/MarkupSafe-1.0/tests.py 2017-03-07 16:30:16.000000000 +0100 @@ -0,0 +1,208 @@ +#!/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, PY2 + + +class MarkupTestCase(unittest.TestCase): + + def test_adding(self): + # adding two strings should escape the unsafe one + unsafe = '<script type="application/x-some-script">alert("foo");</script>' + safe = Markup('<em>username</em>') + assert unsafe + safe == text_type(escape(unsafe)) + text_type(safe) + + def test_string_interpolation(self): + # string interpolations are safe to use too + assert Markup('<em>%s</em>') % '<bad user>' == \ + '<em><bad user></em>' + assert Markup('<em>%(username)s</em>') % { + 'username': '<bad user>' + } == '<em><bad user></em>' + + assert Markup('%i') % 3.14 == '3' + assert Markup('%.2f') % 3.14 == '3.14' + + def test_type_behavior(self): + # an escaped object is markup too + assert type(Markup('foo') + 'bar') is Markup + + # and it implements __html__ by returning itself + x = Markup("foo") + assert x.__html__() is x + + def test_html_interop(self): + # it also knows how to treat __html__ objects + class Foo(object): + def __html__(self): + return '<em>awesome</em>' + def __unicode__(self): + return 'awesome' + __str__ = __unicode__ + assert Markup(Foo()) == '<em>awesome</em>' + assert Markup('<strong>%s</strong>') % Foo() == \ + '<strong><em>awesome</em></strong>' + + def test_tuple_interpol(self): + self.assertEqual(Markup('<em>%s:%s</em>') % ( + '<foo>', + '<bar>', + ), 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>')) + self.assertEqual(Markup('<em>%(foo)s:%(bar)s</em>') % { + 'foo': '<foo>', + 'bar': '<bar>', + }, Markup(u'<em><foo>:<bar></em>')) + + def test_escaping(self): + # 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 ( + (Markup('%i') % 3.14, '3'), + (Markup('%.2f') % 3.14159, '3.14'), + (Markup('%s %s %s') % ('<', 123, '>'), '< 123 >'), + (Markup('<em>{awesome}</em>').format(awesome='<awesome>'), + '<em><awesome></em>'), + (Markup('{0[1][bar]}').format([0, {'bar': '<bar/>'}]), + '<bar/>'), + (Markup('{0[1][bar]}').format([0, {'bar': Markup('<bar/>')}]), + '<bar/>')): + assert actual == expected, "%r should be %r!" % (actual, expected) + + # This is new in 2.7 + if sys.version_info >= (2, 7): + def test_formatting_empty(self): + formatted = Markup('{}').format(0) + assert formatted == Markup('0') + + def test_custom_formatting(self): + class HasHTMLOnly(object): + def __html__(self): + return Markup('<foo>') + + class HasHTMLAndFormat(object): + def __html__(self): + return Markup('<foo>') + def __html_format__(self, spec): + return Markup('<FORMAT>') + + assert Markup('{0}').format(HasHTMLOnly()) == Markup('<foo>') + assert Markup('{0}').format(HasHTMLAndFormat()) == Markup('<FORMAT>') + + def test_complex_custom_formatting(self): + class User(object): + def __init__(self, id, username): + self.id = id + self.username = username + def __html_format__(self, format_spec): + if format_spec == 'link': + return Markup('<a href="/user/{0}">{1}</a>').format( + self.id, + self.__html__(), + ) + elif format_spec: + raise ValueError('Invalid format spec') + return self.__html__() + def __html__(self): + return Markup('<span class=user>{0}</span>').format(self.username) + + user = User(1, 'foo') + 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__: + getattr(markup, item) + + def test_escape_silent(self): + assert escape_silent(None) == Markup() + assert escape(None) == Markup(None) + assert escape_silent('<foo>') == Markup(u'<foo>') + + def test_splitting(self): + self.assertEqual(Markup('a b').split(), [ + Markup('a'), + Markup('b') + ]) + self.assertEqual(Markup('a b').rsplit(), [ + Markup('a'), + Markup('b') + ]) + self.assertEqual(Markup('a\nb').splitlines(), [ + Markup('a'), + Markup('b') + ]) + + def test_mul(self): + self.assertEqual(Markup('a') * 3, Markup('aaa')) + + +class MarkupLeakTestCase(unittest.TestCase): + + def test_markup_leaks(self): + counts = set() + for count in range(20): + for item in range(1000): + escape("foo") + 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, got: ' + str(len(counts)) + + +def suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(MarkupTestCase)) + + # this test only tests the c extension + if not hasattr(escape, 'func_code'): + suite.addTest(unittest.makeSuite(MarkupLeakTestCase)) + + return suite + + +if __name__ == '__main__': + unittest.main(defaultTest='suite') + +# vim:sts=4:sw=4:et:
