Skip to content

Commit

Permalink
Merge branch 'master' into stable/0.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgestar committed Jun 14, 2024
2 parents 12954b8 + 86907b6 commit de984fc
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", pypy2, pypy3]

steps:
- uses: actions/checkout@v2
Expand Down
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
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)
Expand Down
17 changes: 10 additions & 7 deletions genshi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
except ImportError:
import _ast as ast
import sys
import warnings
from types import CodeType

import six
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion genshi/filters/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def __init__(self, safe_tags=SAFE_TAGS, safe_attrs=SAFE_ATTRS,
# IE6 <http://openmya.hacker.jp/hasegawa/security/expression.txt>
# 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.
Expand Down
13 changes: 13 additions & 0 deletions genshi/filters/tests/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,19 @@ def test_translate_included_attribute_text_with_spaces(self):
<span title="Voh">...</span>
</html>""", tmpl.generate().render())

def test_translate_nested_directives(self):
html = """<html xmlns:py="http://genshi.edgewall.org/">
<py:with vars="x = 'test'"><py:if test="x">
</py:if></py:with>
</html>"""
tmpl = MarkupTemplate(html)
raw = tmpl.generate().render()
tmpl = MarkupTemplate(html)
translator = Translator(DummyTranslations())
translator.setup(tmpl)
translated = tmpl.generate().render()
self.assertEqual(raw, translated)


class MsgDirectiveTestCase(unittest.TestCase):

Expand Down
9 changes: 6 additions & 3 deletions genshi/template/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,14 @@ 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
# 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]
directives += added_directives

Expand Down
29 changes: 3 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,12 @@
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://genshi.edgewall.org/log/.

import os
from setuptools import setup, Extension
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsPlatformError
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
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')
Expand Down Expand Up @@ -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,):
Expand Down

0 comments on commit de984fc

Please sign in to comment.