From 6272a4cc4354ffbacf1458f369d987d5f0f877b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 6 Sep 2021 10:23:45 +0200 Subject: [PATCH 01/11] Add test to compare stream with and without translator filter --- genshi/filters/tests/i18n.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/genshi/filters/tests/i18n.py b/genshi/filters/tests/i18n.py index 80d0924..aecc005 100644 --- a/genshi/filters/tests/i18n.py +++ b/genshi/filters/tests/i18n.py @@ -301,6 +301,19 @@ def test_translate_included_attribute_text_with_spaces(self): ... """, tmpl.generate().render()) + def test_translate_nested_directives(self): + html = """ + + + """ + tmpl = MarkupTemplate(html) + stream = list(tmpl.stream) + tmpl = MarkupTemplate(html) + translator = Translator(DummyTranslations()) + translator.setup(tmpl) + stream_translator = list(tmpl.stream) + self.assertEqual(stream, stream_translator) + class MsgDirectiveTestCase(unittest.TestCase): From bc8eaaa9804423ab7f5cb2164337308d8cd9b844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 7 Nov 2021 15:53:53 +0100 Subject: [PATCH 02/11] Compare rendered results --- genshi/filters/tests/i18n.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/genshi/filters/tests/i18n.py b/genshi/filters/tests/i18n.py index aecc005..18548f2 100644 --- a/genshi/filters/tests/i18n.py +++ b/genshi/filters/tests/i18n.py @@ -307,12 +307,12 @@ def test_translate_nested_directives(self): """ tmpl = MarkupTemplate(html) - stream = list(tmpl.stream) + raw = tmpl.generate().render() tmpl = MarkupTemplate(html) translator = Translator(DummyTranslations()) translator.setup(tmpl) - stream_translator = list(tmpl.stream) - self.assertEqual(stream, stream_translator) + translated = tmpl.generate().render() + self.assertEqual(raw, translated) class MsgDirectiveTestCase(unittest.TestCase): From 4fdd135c0aed15582da7024169f773c43fd66c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 7 Nov 2021 15:54:18 +0100 Subject: [PATCH 03/11] Do not merge sub directives if they have not been changed When extracting new directives only new sub directives must be merged in the parent sub directive. Fixes #48 --- genshi/template/markup.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/genshi/template/markup.py b/genshi/template/markup.py index 22f0602..fdece21 100644 --- a/genshi/template/markup.py +++ b/genshi/template/markup.py @@ -172,11 +172,13 @@ def _extract_directives(self, stream, namespace, factory): ] elif kind is SUB: - directives, substream = data - substream = self._extract_directives(substream, namespace, + directives, prev_substream = data + substream = self._extract_directives(prev_substream, namespace, factory) - if len(substream) == 1 and substream[0][0] is SUB: + if (len(substream) == 1 and substream[0][0] is SUB + and (prev_substream[0][0] is not SUB + or prev_substream[0][1][0] != substream[0][1][0])): added_directives, substream = substream[0][1] directives += added_directives From ed317c0b7a94655add18007055ba124e68a0d4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 17 Nov 2021 23:55:09 +0100 Subject: [PATCH 04/11] Add comment --- genshi/template/markup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/genshi/template/markup.py b/genshi/template/markup.py index fdece21..dd441b9 100644 --- a/genshi/template/markup.py +++ b/genshi/template/markup.py @@ -177,6 +177,7 @@ def _extract_directives(self, stream, namespace, factory): factory) if (len(substream) == 1 and substream[0][0] is SUB + # merge only if the direct substream has changed and (prev_substream[0][0] is not SUB or prev_substream[0][1][0] != substream[0][1][0])): added_directives, substream = substream[0][1] From 0850374ad9b83e1057ba67c7f9bf73dd13038df3 Mon Sep 17 00:00:00 2001 From: Graham Inggs Date: Thu, 27 Oct 2022 12:58:29 +0200 Subject: [PATCH 05/11] Fix installation with setuptools >= 60 Installation of genshi with recent versions of setuptools fails with: `distutils.errors.DistutilsSetupError: each element of 'ext_modules' option must be an Extension instance or 2-tuple` Setuptools monkeypatches distutils, so change the ordering of imports so that setuptools is imported before distutils. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c14cfa8..b5eb7a3 100755 --- a/setup.py +++ b/setup.py @@ -12,8 +12,6 @@ # individuals. For the exact contribution history, see the revision # history and logs, available at http://genshi.edgewall.org/log/. -from distutils.command.build_ext import build_ext -from distutils.errors import CCompilerError, DistutilsPlatformError import os try: from setuptools import setup, Extension @@ -21,6 +19,8 @@ except ImportError: from distutils.core import setup, Extension bdist_egg = None +from distutils.command.build_ext import build_ext +from distutils.errors import CCompilerError, DistutilsPlatformError import sys sys.path.append(os.path.join('doc', 'common')) From c70de542b56b7a7f4cf6bffe257262c308fbbb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 8 Jun 2024 16:23:26 +0200 Subject: [PATCH 06/11] Do not use deprecated Ellipsis and Str --- genshi/compat.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/genshi/compat.py b/genshi/compat.py index 2f8c481..2abca13 100644 --- a/genshi/compat.py +++ b/genshi/compat.py @@ -20,6 +20,7 @@ except ImportError: import _ast as ast import sys +import warnings from types import CodeType import six @@ -137,13 +138,15 @@ def build_code_chunk(code, filename, name, lineno): # In Python 3.8, Str and Ellipsis was replaced by Constant -try: - _ast_Ellipsis = ast.Ellipsis - _ast_Str = ast.Str - _ast_Str_value = lambda obj: obj.s -except AttributeError: - _ast_Ellipsis = _ast_Str = ast.Constant - _ast_Str_value = lambda obj: obj.value +with warnings.catch_warnings(): + warnings.filterwarnings('error', category=DeprecationWarning) + try: + _ast_Ellipsis = ast.Ellipsis + _ast_Str = ast.Str + _ast_Str_value = lambda obj: obj.s + except (AttributeError, DeprecationWarning): + _ast_Ellipsis = _ast_Str = ast.Constant + _ast_Str_value = lambda obj: obj.value class _DummyASTItem(object): pass From 88a51e4f8126c8dc33a4a72370d495226d828f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 8 Jun 2024 17:10:03 +0200 Subject: [PATCH 07/11] Use ubuntu 20.04 for Python 2.7 and 3.6 --- .github/workflows/release.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66e300d..d932b39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ on: jobs: build_sdist: name: Build sdist - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -37,7 +37,7 @@ jobs: build_generic_wheel: name: Build generic wheel (without speedups) - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 env: # Build a wheel without speedups that can run on pure Python GENSHI_BUILD_SPEEDUP: 0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a25af71..3488d6e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,10 +4,10 @@ on: [push, pull_request] jobs: tests: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: - python-version: [2.7, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11-dev", pypy2, pypy3] + python-version: [2.7, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11", pypy2, pypy3] steps: - uses: actions/checkout@v2 From 26b67972657787002d3d38c1fded7eef90476ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 8 Jun 2024 21:28:41 +0200 Subject: [PATCH 08/11] Remove tests for python 2.7 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3488d6e..2037fa0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: [2.7, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11", pypy2, pypy3] + python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", pypy2, pypy3] steps: - uses: actions/checkout@v2 From 89e50d7662f75dda6e5ca2c43849048c5e902193 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Thu, 13 Jun 2024 23:25:20 +0200 Subject: [PATCH 09/11] Remove fallback to distutils, patching of bdist_egg and use of doctools. --- setup.py | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index b5eb7a3..a0f98d4 100755 --- a/setup.py +++ b/setup.py @@ -13,22 +13,11 @@ # history and logs, available at http://genshi.edgewall.org/log/. import os -try: - from setuptools import setup, Extension - from setuptools.command.bdist_egg import bdist_egg -except ImportError: - from distutils.core import setup, Extension - bdist_egg = None +from setuptools import setup, Extension from distutils.command.build_ext import build_ext from distutils.errors import CCompilerError, DistutilsPlatformError import sys -sys.path.append(os.path.join('doc', 'common')) -try: - from doctools import build_doc, test_doc -except ImportError: - build_doc = test_doc = None - _speedup_available = False is_pypy = hasattr(sys, 'pypy_version_info') @@ -75,19 +64,7 @@ def _unavailable(self, exc): if _speedup_enabled: ext_modules.append(Extension('genshi._speedups', ['genshi/_speedups.c'])) - -# Setuptools need some help figuring out if the egg is "zip_safe" or not -if bdist_egg: - class my_bdist_egg(bdist_egg): - def zip_safe(self): - return not _speedup_available and bdist_egg.zip_safe(self) - - -cmdclass = {'build_doc': build_doc, 'test_doc': test_doc, - 'build_ext': optional_build_ext} -if bdist_egg: - cmdclass['bdist_egg'] = my_bdist_egg - +cmdclass = {'build_ext': optional_build_ext} extra = {} if sys.version_info >= (3,): From 9d1730bc422ad3d15f94fa1338175cdfa63bc294 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Fri, 14 Jun 2024 06:09:26 +0200 Subject: [PATCH 10/11] Clarify the escaping in _URL_FINDER. --- genshi/filters/html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genshi/filters/html.py b/genshi/filters/html.py index 1705a17..2365b5c 100644 --- a/genshi/filters/html.py +++ b/genshi/filters/html.py @@ -354,7 +354,7 @@ def __init__(self, safe_tags=SAFE_TAGS, safe_attrs=SAFE_ATTRS, # IE6 # 7) Particular bit of Unicode characters _URL_FINDITER = re.compile( - u'[Uu][Rr\u0280][Ll\u029F]%s*\(([^)]+)' % (r'\s')).finditer + u'[Uu][Rr\u0280][Ll\u029F]%s*\\(([^)]+)' % (r'\s')).finditer def __call__(self, stream): """Apply the filter to the given stream. From 433d139f5166e32c01db1f344d3c85da5c2d01df Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Fri, 14 Jun 2024 06:33:47 +0200 Subject: [PATCH 11/11] Update changelog. --- ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3d85ff5..c6be853 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,20 @@ http://svn.edgewall.org/repos/genshi/tags/0.8.0/ * ??? +Version 0.7.8 +https://github.com/edgewall/genshi/releases/tag/0.7.8 +(Jun 24 2024, from branches/stable/0.7.x) + +* Do not merge sub directives if they have not been changed. + (#53 by Cédric Krier) +* Silence deprecation warnings from attempting to import Ellipsis and + Str (which are needed to support older Pythons). (#73 by Cédric Krier) +* Remove fallback to distutils, patching of bdist_egg and use of doctools. + (#74 by Simon Cross) +* Clarify the escaping in _URL_FINDER. (#76 by Simon Cross) +* Fix installation with setuptools >= 60. (#68 by Graham Inggs) + + Version 0.7.7 https://github.com/edgewall/genshi/releases/tag/0.7.7 (Apr 21 2022, from branches/stable/0.7.x)