diff options
-rw-r--r-- | dev-python/tempita/files/tempita-0.5.3-2to3.patch | 233 | ||||
-rw-r--r-- | dev-python/tempita/files/tempita-0.5.3-pypy-tests.patch | 26 | ||||
-rw-r--r-- | dev-python/tempita/tempita-0.5.3-r3.ebuild | 20 |
3 files changed, 240 insertions, 39 deletions
diff --git a/dev-python/tempita/files/tempita-0.5.3-2to3.patch b/dev-python/tempita/files/tempita-0.5.3-2to3.patch new file mode 100644 index 000000000000..d2aaae6546c1 --- /dev/null +++ b/dev-python/tempita/files/tempita-0.5.3-2to3.patch @@ -0,0 +1,233 @@ +commit d886499651add63bbb944c25fc56a276cc2a7884 +Author: Louis Sautier <sautier.louis@gmail.com> +Date: Thu Sep 9 23:35:03 2021 +0200 + + Stop using deprecated 2to3 option for setuptools + +diff --git a/setup.py b/setup.py +index f575020..678b555 100644 +--- a/setup.py ++++ b/setup.py +@@ -36,5 +36,4 @@ more to learn about it. + test_suite='nose.collector', + include_package_data=True, + zip_safe=True, +- use_2to3=True, + ) +diff --git a/tempita/__init__.py b/tempita/__init__.py +index acc2fd9..a3cb8a1 100755 +--- a/tempita/__init__.py ++++ b/tempita/__init__.py +@@ -35,9 +35,9 @@ import os + import re + import sys + import tokenize +-from cStringIO import StringIO ++from io import StringIO + from html import escape +-from urllib import quote as url_quote ++from urllib.parse import quote as url_quote + from tempita._looper import looper + from tempita.compat3 import bytes, basestring_, next, is_unicode, coerce_text + +@@ -103,7 +103,7 @@ class Template(object): + delimiters = (self.default_namespace['start_braces'], + self.default_namespace['end_braces']) + else: +- assert len(delimiters) == 2 and all([isinstance(delimeter, basestring) ++ assert len(delimiters) == 2 and all([isinstance(delimeter, str) + for delimeter in delimiters]) + self.default_namespace = self.__class__.default_namespace.copy() + self.default_namespace['start_braces'] = delimiters[0] +@@ -198,7 +198,7 @@ class Template(object): + position=None, name=self.name) + templ = self.get_template(inherit_template, self) + self_ = TemplateObject(self.name) +- for name, value in defs.iteritems(): ++ for name, value in defs.items(): + setattr(self_, name, value) + self_.body = body + ns = ns.copy() +@@ -294,7 +294,7 @@ class Template(object): + try: + try: + value = eval(code, self.default_namespace, ns) +- except SyntaxError, e: ++ except SyntaxError as e: + raise SyntaxError( + 'invalid syntax in expression: %s' % code) + return value +@@ -306,12 +306,12 @@ class Template(object): + else: + arg0 = coerce_text(e) + e.args = (self._add_line_info(arg0, pos),) +- raise exc_info[0], e, exc_info[2] ++ raise exc_info[0](e).with_traceback(exc_info[2]) + + def _exec(self, code, ns, pos): + __traceback_hide__ = True + try: +- exec code in self.default_namespace, ns ++ exec(code, self.default_namespace, ns) + except: + exc_info = sys.exc_info() + e = exc_info[1] +@@ -319,7 +319,7 @@ class Template(object): + e.args = (self._add_line_info(e.args[0], pos),) + else: + e.args = (self._add_line_info(None, pos),) +- raise exc_info[0], e, exc_info[2] ++ raise exc_info[0](e).with_traceback(exc_info[2]) + + def _repr(self, value, pos): + __traceback_hide__ = True +@@ -328,7 +328,7 @@ class Template(object): + return '' + if self._unicode: + try: +- value = unicode(value) ++ value = str(value) + except UnicodeDecodeError: + value = bytes(value) + else: +@@ -341,7 +341,7 @@ class Template(object): + exc_info = sys.exc_info() + e = exc_info[1] + e.args = (self._add_line_info(e.args[0], pos),) +- raise exc_info[0], e, exc_info[2] ++ raise exc_info[0](e).with_traceback(exc_info[2]) + else: + if self._unicode and isinstance(value, bytes): + if not self.default_encoding: +@@ -350,7 +350,7 @@ class Template(object): + '(no default_encoding provided)' % value) + try: + value = value.decode(self.default_encoding) +- except UnicodeDecodeError, e: ++ except UnicodeDecodeError as e: + raise UnicodeDecodeError( + e.encoding, + e.object, +@@ -387,7 +387,7 @@ def paste_script_template_renderer(content, vars, filename=None): + class bunch(dict): + + def __init__(self, **kw): +- for name, value in kw.iteritems(): ++ for name, value in kw.items(): + setattr(self, name, value) + + def __setattr__(self, name, value): +@@ -410,7 +410,7 @@ class bunch(dict): + + def __repr__(self): + items = [ +- (k, v) for k, v in self.iteritems()] ++ (k, v) for k, v in self.items()] + items.sort() + return '<%s %s>' % ( + self.__class__.__name__, +@@ -463,7 +463,7 @@ def url(v): + + + def attr(**kw): +- kw = list(kw.iteritems()) ++ kw = list(kw.items()) + kw.sort() + parts = [] + for name, value in kw: +@@ -545,7 +545,7 @@ class TemplateDef(object): + values = {} + sig_args, var_args, var_kw, defaults = self._func_signature + extra_kw = {} +- for name, value in kw.iteritems(): ++ for name, value in kw.items(): + if not var_kw and name not in sig_args: + raise TypeError( + 'Unexpected argument %s' % name) +@@ -568,7 +568,7 @@ class TemplateDef(object): + raise TypeError( + 'Extra position arguments: %s' + % ', '.join(repr(v) for v in args)) +- for name, value_expr in defaults.iteritems(): ++ for name, value_expr in defaults.items(): + if name not in values: + values[name] = self._template._eval( + value_expr, self._ns, self._pos) +@@ -614,7 +614,7 @@ class _Empty(object): + return 'Empty' + + def __unicode__(self): +- return u'' ++ return '' + + def __iter__(self): + return iter(()) +@@ -1164,7 +1164,7 @@ def fill_command(args=None): + vars.update(os.environ) + for value in args: + if '=' not in value: +- print('Bad argument: %r' % value) ++ print(('Bad argument: %r' % value)) + sys.exit(2) + name, value = value.split('=', 1) + if name.startswith('py:'): +diff --git a/tempita/_looper.py b/tempita/_looper.py +index 6784c7c..70aded7 100644 +--- a/tempita/_looper.py ++++ b/tempita/_looper.py +@@ -7,9 +7,9 @@ These can be awkward to manage in a normal Python loop, but using the + looper you can get a better sense of the context. Use like:: + + >>> for loop, item in looper(['a', 'b', 'c']): +- ... print loop.number, item ++ ... print(loop.number, item) + ... if not loop.last: +- ... print '---' ++ ... print('---') + 1 a + --- + 2 b +@@ -161,3 +161,4 @@ class loop_pos(object): + return getter(item) != getter(other) + else: + return item[getter] != other[getter] ++ +diff --git a/tempita/compat3.py b/tempita/compat3.py +index 5e18fa0..f17f588 100644 +--- a/tempita/compat3.py ++++ b/tempita/compat3.py +@@ -4,7 +4,7 @@ __all__ = ['b', 'basestring_', 'bytes', 'next', 'is_unicode'] + + if sys.version < "3": + b = bytes = str +- basestring_ = basestring ++ basestring_ = str + else: + + def b(s): +@@ -18,14 +18,14 @@ text = str + if sys.version < "3": + + def next(obj): +- return obj.next() ++ return obj.__next__() + else: + next = next + + if sys.version < "3": + + def is_unicode(obj): +- return isinstance(obj, unicode) ++ return isinstance(obj, str) + else: + + def is_unicode(obj): +@@ -39,7 +39,7 @@ def coerce_text(v): + else: + attr = '__str__' + if hasattr(v, attr): +- return unicode(v) ++ return str(v) + else: + return bytes(v) + return v diff --git a/dev-python/tempita/files/tempita-0.5.3-pypy-tests.patch b/dev-python/tempita/files/tempita-0.5.3-pypy-tests.patch deleted file mode 100644 index cdef27276be5..000000000000 --- a/dev-python/tempita/files/tempita-0.5.3-pypy-tests.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/docs/index.txt b/docs/index.txt -index 6d943f6..afe3aa2 100644 ---- a/docs/index.txt -+++ b/docs/index.txt -@@ -82,7 +82,7 @@ error (the name will be displayed):: - >>> tmpl.substitute() - Traceback (most recent call last): - ... -- NameError: name 'name' is not defined at line 1 column 6 in file tmpl -+ NameError:... name 'name' is not defined at line 1 column 6 in file tmpl - - You can also give a namespace to use by default, which - ``.substitute(...)`` will augment:: -diff --git a/tests/test_template.txt b/tests/test_template.txt -index 9564a9a..d9eb55d 100644 ---- a/tests/test_template.txt -+++ b/tests/test_template.txt -@@ -144,7 +144,7 @@ for a variable, if no value is given:: - >>> sub('{{x}}') - Traceback (most recent call last): - ... -- NameError: name 'x' is not defined at line 1 column 3 -+ NameError:... name 'x' is not defined at line 1 column 3 - - And comments work:: - diff --git a/dev-python/tempita/tempita-0.5.3-r3.ebuild b/dev-python/tempita/tempita-0.5.3-r3.ebuild index 6d5c3b27dc97..be3b68c6bb55 100644 --- a/dev-python/tempita/tempita-0.5.3-r3.ebuild +++ b/dev-python/tempita/tempita-0.5.3-r3.ebuild @@ -1,9 +1,9 @@ # Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -EAPI=7 +EAPI=8 -PYTHON_COMPAT=( pypy3 python3_{7..10} ) +PYTHON_COMPAT=( pypy3 python3_{8..10} ) # The package uses pkg_resources DISTUTILS_USE_SETUPTOOLS=manual @@ -20,22 +20,19 @@ S="${WORKDIR}/ianb-${PN}-${MY_COMMIT}" LICENSE="MIT" SLOT="0" KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux" -IUSE="test" -RESTRICT="!test? ( test )" RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]" -BDEPEND=" - dev-python/setuptools[${PYTHON_USEDEP}] - test? ( dev-python/pytest[${PYTHON_USEDEP}] ) -" +BDEPEND="${RDEPEND}" PATCHES=( - "${FILESDIR}/${P}-pypy-tests.patch" # cgi.escape has been removed in Python 3.9 "${FILESDIR}/${P}-cgi-escape.patch" + # The 2to3 option for setuptools is deprecated + "${FILESDIR}/${P}-2to3.patch" ) distutils_enable_sphinx docs +distutils_enable_tests pytest python_prepare_all() { # Remove reference to a non-existent CSS file @@ -45,8 +42,5 @@ python_prepare_all() { } python_test() { - # We need to append to sys.path, otherwise pytest imports - # the module from ${S} (before it was 2to3'd) - pytest --import-mode=append -vv tests/test_template.txt docs/index.txt \ - || die "Tests failed with ${EPYTHON}" + epytest tests/test_template.txt docs/index.txt } |